ThinkPHP某个Controlller调用公共function的方法导致500(Internal Server Error)

thinkphp3.2.3版本。
我在项目中新增了一个SupportController,其中有个方法如下

    public function index(){         
        $url="http://www.baidu.com";
        var_dump(check_remote_url($img_qiniu)); //check_remote_url是common/function中的方法
        //如果把上面这行注释就不会报错500 (Internal Server Error)
    }

check_remote_url是公共函数common/function中的方法,只要一使用就报错500 (Internal Server Error),注释掉又好了。
不光是这个check_remote_url,只要这个新增的控制器使用公共函数中的方法都报错。

补充:最诡异的是,在我没新增之前,项目本身有个TestController,其中也有使用公共函数common/function中的方法,但是没有任何问题。

请问是什么原因???

阅读 2.7k
1 个回答

原因当然是 common 下的某个文件有错误,500 如果页面空白的话,需要打开php的错误提示。或者在index.php中加入以下代码,就能看到错误信息

error_reporting(E_ALL); //E_ALL  
   
function cache_shutdown_error() {  
   
    $_error = error_get_last();  
   
    if ($_error && in_array($_error['type'], array(1, 4, 16, 64, 256, 4096, E_ALL))) {  
   
        echo '<font color=red>你的代码出错了:</font></br>';  
        echo '致命错误:' . $_error['message'] . '</br>';  
        echo '文件:' . $_error['file'] . '</br>';  
        echo '在第' . $_error['line'] . '行</br>';  
    }  
}  
   
register_shutdown_function("cache_shutdown_error");  
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题