source

컬이 활성화 또는 비활성화되었는지 확인하는 방법

itover 2023. 1. 15. 10:23
반응형

컬이 활성화 또는 비활성화되었는지 확인하는 방법

중복 가능성:
함수를 php로 쓰는 중

다음 코드를 사용하고 있습니다.

echo 'Curl: ', function_exists('curl_version') ? 'Enabled' : 'Disabled';

활성화 또는 비활성화 시킬 수 있습니다.

하지만 기능명은 함수로 하고 싶습니다._iscurl

그러면 내 웹사이트 코드의 어느 곳에서도 다음과 같이 부를 수 있다.

if (_iscurl()){
  echo "this is enabled"; // will do an action
}else{
  echo "this is disabled"; // will do another action
}

이전 질문과 거의 동일하게 allow_url_fopen이 활성화 되어 있는지 확인합니다.

함수에서 기존 수표를 반환하기만 하면 됩니다.

function _isCurl(){
    return function_exists('curl_version');
}
<?php

// Script to test if the CURL extension is installed on this server

// Define function to test
function _is_curl_installed() {
    if  (in_array  ('curl', get_loaded_extensions())) {
        return true;
    }
    else {
        return false;
    }
}

// Ouput text to user based on test
if (_is_curl_installed()) {
  echo "cURL is <span style=\"color:blue\">installed</span> on this server";
} else {
  echo "cURL is NOT <span style=\"color:red\">installed</span> on this server";
}
?>

또는 단순한 것-

<?
phpinfo();
?>

컬 검색만 하면 됩니다.

출처 - http://www.mattsbits.co.uk/item-164.html

var_dump(extension_loaded('curl'));

이게 도움이 됐으면 좋겠다.

<?php
    function _iscurl() {
        return function_exists('curl_version');
    }
?>

이 코드를 php 파일에 넣으면 확인할 수 있습니다.

<?php
if(in_array  ('curl', get_loaded_extensions())) {
    echo "CURL is available on your web server";
}
else{
    echo "CURL is not available on your web server";
}

또는

var_dump(extension_loaded('curl'));

언제든지 새 페이지를 만들어 사용할 수 있습니다.phpinfo(). 아래로 스크롤하여 컬 섹션이 활성화 되어 있는지 확인합니다.

프로젝트에서는 확장 로드 여부를 반환하는 일반적인 재사용 가능 함수를 사용하는 것이 좋습니다.다음 기능을 사용하여 확인할 수 있습니다.

function isExtensionLoaded($extension_name){
    return extension_loaded($extension_name);
}

사용.

echo isExtensionLoaded('curl');
echo isExtensionLoaded('gd');

언급URL : https://stackoverflow.com/questions/13433946/how-to-check-if-curl-is-enabled-or-disabled

반응형