【发布时间】:2013-10-19 20:36:08
【问题描述】:
我的班级有以下方法:
public function __construct(){
$this->handle = curl_init();
}
public function setOptArrayAndExecute(){
$curlArray = curl_setopt_array(
$this->handle,
array(
CURLOPT_URL => $this->getUrl(),
CURLOPT_USERAGENT => $this->getUserAgent(),
CURLOPT_COOKIEJAR => $this->getCookie(),
CURLOPT_COOKIEFILE => $this->getCookie(),
CURLOPT_REFERER => $this->getReferer(),
CURLOPT_TIMEOUT => $this->getTimeOut(),
CURLOPT_FOLLOWLOCATION => true
)
);
ob_start(); //<-- Execution stops here
curl_exec($this->handle);
$this->response = ob_get_contents();
curl_close($this->handle);
ob_end_clean();
return $this->response;
}
所以我只写了代码的特定部分而不是整个类。 我看了我的 php.ini:输出缓冲设置为“开”。我也激活了错误报告:
error_reporting(E_ALL);
ini_set('display_errors', 1);
我的 PHP 版本是 5.4.3。
该脚本仅在ob_start() 停止,没有任何通知或错误报告...
我不知道我错过了什么或我做错了什么。非常感谢您的帮助。
【问题讨论】:
-
我认为
ob_start没有问题。删除ob_start和ob_end_clean,然后重新运行您的代码。对象缓冲导致ob_end_clean();之前生成的任何错误或警告被抑制。 -
是的。你是对的。我忘记了网址的“http://”。感谢您的提示。所以我猜缓冲区无法加载,但我不明白为什么代码总是停止在 ob_start 上工作
标签: php curl methods buffer ob-start