PHP报错合集以及解决方法

记录个人PHP运行时的报错信息以及解决方法,后续不断更新。 a1490bb4c4a2c7fb3e4240e8b84d7eab.png

  • 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’] 就行啦~

Licensed under CC BY-NC-SA 4.0
最后更新于 Mar 25, 2017 10:52 UTC
点击刷新🚌