如何防止cURL错误:警告:出于安全原因,已禁用curl_exec()

Hello I have a script the uses cURL, It can be executed in many different hosts I don't know it's configuration. I have a check script, but I still get cURL errors in some hosts.

My script

if (!in_array('curl', get_loaded_extensions())) {
    // bad configuration message goes here, exit the app
}

Error I get in some hosts:

Warning: curl_exec() has been disabled for security reasons

My question is how should I code my script to fully check cURL availability in the server

Thks

Write something like this..

echo function_exists('curl_version')?"You have it ;)":"You don't have cURL!!";

and I get an output on my screen as ..

OUTPUT :

You have it ;)

Use function_exists. It also reports false for disabled functions.

That's not explicitly documented, but source code describes it well: http://lxr.php.net/xref/PHP_5_6/Zend/zend_builtin_functions.c#1384.