php怎么隐藏错误信息,PHP错误级别处置,隐藏错误信息

PHP错误级别处置,隐藏错误信息

PHP错误级别:

4588749ba8b645961246f43b8e1a2eca.png

1.最低级别错误—Deprecated

if(ereg('china','this is china',$matches)){print_r($matches);

}else{echo 'not find';

}

00aaa26701db60f4651a60c31e34cfc5.png

2.通知级别错误—Notice(抛出报错信息,程序继续向下执行)

echo $num;

3.忠告级别错误—Warning

4.致命级别错误—Fatal(抛出报错信息,程序不能向下执行)

5.语法剖析错误—Parse(最高级别错误,程序不能执行)

1.显示所有错误一:

error_reporting(E_ALL&~E_NOTICE);//不显示所有错误

error_reporting(0);//显示错误

error_reporting(-1);//in_set() 运行时设置设置选项的值

in_set('error_reporting',0);

in_set('error_reporting',-1);

in_set('display_errors',0);

2.PHP错误处置:

7b3f3d7c485387138df68ae1aa0bcd16.png

修改php.ini

;

; Error Level Constants:

; E_ALL             - All errors and warnings (includes E_STRICT as of PHP 5.4.0)

; E_ERROR           - fatal run-time errors

; E_RECOVERABLE_ERROR  - almost fatal run-time errors

; E_WARNING         - run-time warnings (non-fatal errors)

; E_PARSE           - compile-time parse errors

; E_NOTICE          - run-time notices (these are warnings which often result

;                     from a bug in your code, but it's possible that it was

;                     intentional (e.g., using an uninitialized variable and

;                     relying on the fact it's automatically initialized to an

;                     empty string)

; E_STRICT          - run-time notices, enable to have PHP suggest changes

;                     to your code which will ensure the best interoperability

;                     and forward compatibility of your code

; E_CORE_ERROR      - fatal errors that occur during PHP's initial startup

; E_CORE_WARNING    - warnings (non-fatal errors) that occur during PHP's

;                     initial startup

; E_COMPILE_ERROR   - fatal compile-time errors

; E_COMPILE_WARNING - compile-time warnings (non-fatal errors)

; E_USER_ERROR      - user-generated error message

; E_USER_WARNING    - user-generated warning message

; E_USER_NOTICE     - user-generated notice message

; E_DEPRECATED      - warn about code that will not work in future versions

;                     of PHP

; E_USER_DEPRECATED - user-generated deprecation warningserror_reporting = E_ALL&~E_NOTICR&E_DEPRECATED&~E_STRICT

55ccbd9e7c0a36b32c87870b6e06d29a.png

b26dfb519bbf3bcc508b3e07add827d0.png

4.PHP通过trigger_error()触发PHP错误

if(!(is_numberic($num1)&& is_numeric($num2))){

//trigger_error('num1 和 num2 必须为正当数值',E_USER_NOTICE);

//trigger_error('num1 和 num2 必须为正当数值',E_USER_WARNING);

trigger_error('num1 和 num2 必须为正当数值',E_USER_ERROR);

}else{echo $num1 + $num2;

}echo '程序继续向下执行!';

原文链接:https://www.cnblogs.com/ccw869476711/p/12846525.html

本站声明:网站内容来源于网络,若有侵权,请联系我们,我们将及时处置。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值