在使用 curl 時出現報錯:
CURLOPT_FOLLOWLOCATION cannot be activated when safe_mode is enabled or an open_basedir is set in ...
safe_mode:PHP安全模式,當開啟時一些PHP函數將被禁用
open_basedir: 將用戶訪問文件的活動范圍限制在指定的區域 如 open_basedir=.:/tmp 或是具體 /var/tmp
解決方法:
if (ini_get('open_basedir') == '' && ini_get('safe_mode' == 'Off')) {
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
}