【发布时间】:2016-10-15 21:14:03
【问题描述】:
我最近将我的测试服务器从 wamp(非常旧的版本)升级到了新版本的 xampp。由于升级我用来提取 CSV 数据的 CURL 失败。
我收到以下错误:
Warning: curl_setopt(): Curl option contains invalid characters (\0)
此错误出现在
$ch = curl_init();
完整的初始化如下:
// CURL Initialisation
$ch = curl_init();
curl_setopt($ch, CURLOPT_PROXY, $proxy);
curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxyAuth);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, $snowAuth);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// Set the URL
curl_setopt($ch, CURLOPT_URL, $URL);
这在网络服务器升级之间根本没有改变。我检查了 php.ini 并验证了 php_curl 已启用并确保 extension_dir 也是正确的(C:/xampp/php/ext)。
有什么想法吗?我现在正在尝试回滚到旧版本的 XAMPP。
编辑:变量的值如下(安全的虚拟数据),也不是从用户输入或外部文件中检索到的:
$proxy = "10.0.0.128:8080"
$proxyAuth = "username:password"
$snowAuth = "diffusername:diffpassword"
【问题讨论】:
-
来自@keupsonite:变量
$proxy、$proxyAuth、$snowAuth的内容是什么?数据来自用户还是其他文件?我认为您的文件中有一个 BOM 字符。您需要将其删除。