note 111975 deleted from function.curl-setopt by cmb
| From: | cmb@php.net | Date: | Sun, 17 Nov 2019 08:56:26 +0000 |
| Subject: | note 111975 deleted from function.curl-setopt by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-213098@lists.php.net to get a copy of this message | ||
Note Submitter: dardyole at hotmail dot com
----
Another note addressing the issues with servers that have open_basedir and safe mode turned on. Such
an issue spawns the following E_WARNING:
Warning: curl_setopt() [function.curl-setopt]: CURLOPT_FOLLOWLOCATION cannot be activated when
safe_mode is enabled or an open_basedir is set
After looking through the notes, most of the proposed manual implementations were kind of clunky and
in some cases just didn't work at all. Most importantly (in my case), was the behaviour of the
302 Header. Anyway, here's the code I ended up using which has worked well for me in all cases
so far, it even addresses the issue that caused FOLLOWLOCATION to be turned off in some cases :)
EDIT: Unfortunately the code itself is deemed "too long" for PHP's note system.
I've uploaded it to a few paste sites below so hopefully the links will live for a while at
least.
http://pastebin.com/aaJtPy1j
http://pastie.org/7646116
Use it as a replacement for curl_exec. For example:
<?php
$ch = curl_init("http://php.net");
var_dump(curl_exec_follow($ch, 9001));
curl_close($ch);
?>