当PHP以cgi
或mod_php
模式执行时,我们可以在php.ini
中禁用错误报告,并使用目录中的.htaccess
文件在每个目录中启用它我们想要的任何目录。
php_flag display_startup_errors 1
php_flag display_errors 1
php_flag html_errors 1
php_value error_reporting -1
在php脚本脚本本身中执行此操作是没有用的,因为它会中断php解析错误,这是很常见的错误。
在运行php-fpm
执行模式时,我该怎么做?有可能吗?
答案 0 :(得分:2)
使用fpm时,PHP会在每个目录中扫描ini文件
http://php.net/manual/en/configuration.file.per-user.php
默认值为.user.ini
您应该能够在其中放置相同的配置,但语法与php.ini相同:
display_errors = On
display_startup_errors = On
html_errors = 1
error_reporting = -1