首先是关于PHP在PHP 5.2以上启用safe_mode or an open_basedir会导致CURLOPT_FOLLOWLOCATION失败,再导致curl_setopt/curl_setopt_array失败。
官方对此有声明如下:
Starting in PHP 5.2.0, CURLOPT_FOLLOWLOCATION can't be set via curl_setopt_array() (or curl_setopt()) when either safe_mode is enabled or open_basedir is set. In these cases, the order of CURLOPT_* settings in the array can be important.
1.CURLOPT_FOLLOWLOCATION
Warning: curl_setopt() [function.curl-setopt]: CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set
2.curl_setopt_array()
如果curl_setopt_array中包含CURLOPT_FOLLOWLOCATION键值,会导致所有options设置失败,让你感觉curl_setopt_array有问题,其实这个函数本身是没问题的。