在php中开启与关闭错误提示的方法有几种一种可以直接在程序中使用相关函数来开户,另一种我们可以使用php.ini中配置参数来控制,接下来吾爱编程给大家介绍一下。
1、如果不具备修改php.ini的权限,可以将如下代码加入php文件中:
ini_set("display_errors", "On"); error_reporting(E_ALL | E_STRICT);
2、如果能够修改php.ini的话,把display_errors对应参数改为On即可,如下:
display_errors = Off #修改为On display_errors = On
注意:如果你已经把PHP.ini文件复制到windows目录下,那么必须同时把c:windows/php.ini里的display_errors对应参数修改为off,然后重启php服务。
1、 打开php.ini文件。
打开/usr/local/php/etc目录下的php.ini文件,我是使用的lnmp安装的,如果是自己编译的php,请在更改对应文件夹下面的php.ini文件即可。
2、 搜索并修改下行,把On值改成Off
display_errors = Off #修改为On display_errors = On
3、重启php:
service php-fpm restart
如果需要关闭错误提示,我们可以把上述php.ini中的display_errors参数修改为Off即可
display_errors = On #修改为off display_errors = off
然后重启对应php服务即可。