记录个人PHP运行时的报错信息以及解决方法,后续不断更新。
- Fatal error: Uncaught Error: Call to undefined function curl_init()
使用$curl = curl_init();
//初始化一个cURL对象 时遇到的
解决方法:
apt-get insatll php-curl
- PHP Notice: undefined index xxx
$_GET[‘xx’] 取得参数值时,如果之前不加判断在未传进参数时会的警告:
解决方法1:
每个文件头部加上:error_reporting(0);
解决方法2:
打开php.ini,找到display_errors,设置为display_errors = Off。
解决方法3:
定义一个函数:
function _get($str){ $val = !empty($_GET[$str]) ? $_GET[$str] : null; return $val; }
然后在用的时候,直接用 _get(‘str’) 代替 $_GET[‘str’] 就行啦~