"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);

}

 

 

posted @ 2013-05-30 13:39  黑暗行者  阅读(3294)  评论(1编辑  收藏  举报