CURLOPT_RETURNTRANSFER设置为true在托管服务器上不起作用 [英] CURLOPT_RETURNTRANSFER set to true doesnt work on hosting server
问题描述
在我的本地服务器这是很好,但当我把同一个文件在线,它不工作。
当我将 CURLOPT_RETURNTRANSFER
设置为false时,它可以正常工作。
curl_setopt($ ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ ch,CURLOPT_RETURNTRANSFER,TRUE);如果您设置 CURLOPT_RETURNTRANSFER / code>到 true
或 1
,然后返回 curl_exec 将是成功操作的实际结果。换句话说,它不会返回 TRUE
成功。虽然在失败时会返回 FALSE
。
如 curl-exec
PHP手册页: http://php.net/manual/function。 curl-exec.php
您应该为重定向启用 CURLOPT_FOLLOWLOCATION
选项,但这将是一个问题如果你的服务器在 safe_mode
和/或 open_basedir
有效,这也可能导致curl问题。 / p>
On my local server this is fine but when I put the same file online it doesn't work.
When I set CURLOPT_RETURNTRANSFER
to false it works.
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
解决方案 If you set CURLOPT_RETURNTRANSFER
to true
or 1
then the return value from curl_exec
will be the actual result from the successful operation. In other words it will not return TRUE
on success. Although it will return FALSE
on failure.
As described in the Return Values section of curl-exec
PHP manual page: http://php.net/manual/function.curl-exec.php
You should enable the CURLOPT_FOLLOWLOCATION
option for redirects but this would be a problem if your server is in safe_mode
and/or open_basedir
is in effect which can cause issues with curl as well.
这篇关于CURLOPT_RETURNTRANSFER设置为true在托管服务器上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!