我有一个小的 php 脚本,用于测试 cURL 是否已安装并正常运行。这适用于我们的 Oracle 服务云沙箱环境 (websitename.rightnowdemo.com),它在页面顶部和下方显示 google.com,它打印测试功能的结果(“cURL 已安装在此服务器上”) . 但是,我们的开发 (websitename.custhelp.com) 环境中的相同代码不起作用。它只打印“cURL 已安装”消息,仅此而已。在我们的新环境中是否有需要设置的配置设置?我怎样才能让 cURL 充分发挥作用?
代码:
<rn:meta title="cURL Example" template="agent.php" clickstream=""/>
<?php
load_curl();
$curlURL = "www.google.com";
$ch = curl_init($curlURL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_FAILONERROR, 0);
$result = curl_exec($ch);
echo $result;
curl_close($ch);
?>
<html>
<head></head>
<body>
<?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:#4fa361;\">installed</span> on this server";
} else {
echo "cURL is <span style=\"color:#dc4f49\">not installed</span> on this server";
}
?>
</body>
</html>