"CURLOPT_FOLLOWLOCATION cannot be activated when safe_mode is enabled or an open_basedir is set" 问题

在使用 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);

}

 

===================== This is my sign! ======================================================= The moment you want to give up, thing about why did insist to come here !
原文地址:https://www.cnblogs.com/tuozi001/p/3108017.html