IT TIP

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

itqueen 2020. 10. 17. 12:39
반응형

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


중복 가능성 :
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();
?>

curl을 검색하십시오.

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


var_dump(extension_loaded('curl'));

도움이 되었기를 바랍니다.

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

언제든지 새 페이지를 만들고 phpinfo(). curl 섹션까지 아래로 스크롤하여 활성화되었는지 확인합니다.


Its always better to go for a generic reusable function in your project which returns whether the extension loaded. You can use the following function to check -

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

Usage

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

you can check by putting these code in php file.

<?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";
}

OR

var_dump(extension_loaded('curl'));

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

반응형