Php 显示所有错误和警告
更新2: 现在,我已从.php文件中删除以下内容:Php 显示所有错误和警告,php,debugging,warnings,Php,Debugging,Warnings,更新2: 现在,我已从.php文件中删除以下内容: <?php error_reporting( E_ALL ); ?> 可以在php.ini或Apache配置文件中关闭显示错误 您可以在脚本中打开它: error_reporting(E_ALL); ini_set('display_errors', '1'); 您应该在PHP错误日志中看到相同的消息。显示错误可以在PHP.ini或Apache配置文件中关闭 您可以在脚本中打开它: error_reporting(E_ALL);
<?php error_reporting( E_ALL ); ?>
可以在
php.ini
或Apache配置文件中关闭显示错误
您可以在脚本中打开它:
error_reporting(E_ALL);
ini_set('display_errors', '1');
您应该在PHP错误日志中看到相同的消息。显示错误可以在
PHP.ini
或Apache配置文件中关闭
您可以在脚本中打开它:
error_reporting(E_ALL);
ini_set('display_errors', '1');
您应该在PHP错误日志中看到相同的消息。直接从PHP.ini文件:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Error handling and logging ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; This directive informs PHP of which errors, warnings and notices you would like
; it to take action for. The recommended way of setting values for this
; directive is through the use of the error level constants and bitwise
; operators. The error level constants are below here for convenience as well as
; some common settings and their meanings.
; By default, PHP is set to take action on all errors, notices and warnings EXCEPT
; those related to E_NOTICE and E_STRICT, which together cover best practices and
; recommended coding standards in PHP. For performance reasons, this is the
; recommend error reporting setting. Your production server shouldn't be wasting
; resources complaining about best practices and coding standards. That's what
; development servers and development settings are for.
; Note: The php.ini-development file has this setting as E_ALL. This
; means it pretty much reports everything which is exactly what you want during
; development and early testing.
;
; 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 is 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 warnings
;
; Common Values:
; E_ALL (Show all errors, warnings and notices including coding standards.)
; E_ALL & ~E_NOTICE (Show all errors, except for notices)
; E_ALL & ~E_NOTICE & ~E_STRICT (Show all errors, except for notices and coding standards warnings.)
; E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR (Show only errors)
; Default Value: E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED
; Development Value: E_ALL
; Production Value: E_ALL & ~E_DEPRECATED & ~E_STRICT
; http://php.net/error-reporting
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
对于纯开发,我选择:
error_reporting = E_ALL ^ E_NOTICE ^ E_WARNING
另外,别忘了打开“显示错误”
display_errors = On
之后,在Ubuntu上重新启动Apache服务器:
sudo /etc/init.d/apache2 restart
直接从php.ini文件:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Error handling and logging ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; This directive informs PHP of which errors, warnings and notices you would like
; it to take action for. The recommended way of setting values for this
; directive is through the use of the error level constants and bitwise
; operators. The error level constants are below here for convenience as well as
; some common settings and their meanings.
; By default, PHP is set to take action on all errors, notices and warnings EXCEPT
; those related to E_NOTICE and E_STRICT, which together cover best practices and
; recommended coding standards in PHP. For performance reasons, this is the
; recommend error reporting setting. Your production server shouldn't be wasting
; resources complaining about best practices and coding standards. That's what
; development servers and development settings are for.
; Note: The php.ini-development file has this setting as E_ALL. This
; means it pretty much reports everything which is exactly what you want during
; development and early testing.
;
; 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 is 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 warnings
;
; Common Values:
; E_ALL (Show all errors, warnings and notices including coding standards.)
; E_ALL & ~E_NOTICE (Show all errors, except for notices)
; E_ALL & ~E_NOTICE & ~E_STRICT (Show all errors, except for notices and coding standards warnings.)
; E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR (Show only errors)
; Default Value: E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED
; Development Value: E_ALL
; Production Value: E_ALL & ~E_DEPRECATED & ~E_STRICT
; http://php.net/error-reporting
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
对于纯开发,我选择:
error_reporting = E_ALL ^ E_NOTICE ^ E_WARNING
另外,别忘了打开“显示错误”
display_errors = On
之后,在Ubuntu上重新启动Apache服务器:
sudo /etc/init.d/apache2 restart
在
php.ini
上设置这些选项:
;display_startup_errors = On
display_startup_errors=off
display_errors =on
html_errors= on
在PHP页面中,使用适当的过滤器进行错误报告
error_reporting(E_ALL);
可根据需要制作文件管理器
E_ALL
E_ALL | E_STRICT
在
php.ini
上设置这些选项:
;display_startup_errors = On
display_startup_errors=off
display_errors =on
html_errors= on
在PHP页面中,使用适当的过滤器进行错误报告
error_reporting(E_ALL);
可根据需要制作文件管理器
E_ALL
E_ALL | E_STRICT
我能够通过以下代码获得所有错误:
ini_set('display_startup_errors', 1);
ini_set('display_errors', 1);
error_reporting(-1);
我能够通过以下代码获得所有错误:
ini_set('display_startup_errors', 1);
ini_set('display_errors', 1);
error_reporting(-1);
PHP错误可以通过以下任何方法显示:
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
有关详细信息:
PHP错误可以通过以下任何方法显示:
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
有关详细信息:
您可以看到详细的说明 变更日志
- 5.4.0 E_STRICT成为E_ALL的一部分
- 5.3.0引入了不推荐的E_和不推荐的E_用户
- 5.2.0引入了E_可恢复错误
- 5.0.0严格引入了E_(不是E_ALL的一部分)
- 5.4.0 E_STRICT成为E_ALL的一部分
- 5.3.0引入了不推荐的E_和不推荐的E_用户
- 5.2.0引入了E_可恢复错误
- 5.0.0严格引入了E_(不是E_ALL的一部分)
error\u reporting
设置,因为它在脚本中。请参阅原始问题中的更新1:请重新阅读我的问题<代码>显示错误与错误报告
完全不同。此外,您的脚本将覆盖INI文件中设置的错误报告值。INI设置的当前值是多少?我刚刚检查过,它设置为error\u reporting=E\u ALL&~E\u DEPRECATEDPlease重新阅读我的问题,我们已经知道您的错误报告设置,因为它在脚本中。请参阅原始问题中的更新1:请重新阅读我的问题<代码>显示错误
与错误报告
完全不同。另外,您的脚本会覆盖INI文件中的错误报告值集。在更改php.INI文件后是否需要重新启动apache?这个问题已经发布在@oshirowanenINI\u set()
上,实际上并没有更改php.INI
文件,脚本只是“起作用”like在php.ini
中是这样设置的。。。从手动:设置给定配置选项的值。配置选项将在脚本执行期间保留此新值
,
,并且
将在脚本结束时恢复
,
我不知道有多少次得到相同的答案。你帮了我很多。谢谢!:)@Charles为什么E_ALL
删除E_通知
?E_本身不包括所有内容吗,包括E_通知?我需要在更改php.ini文件后重新启动apache吗?这个问题已经发布了@oshirowanenini_set()
实际上并没有更改php.ini
文件,脚本只是像在php.ini
中那样“运行”。。。从手动:设置给定配置选项的值。配置选项将在脚本执行期间保留此新值
,
,并且
将在脚本结束时恢复
,
我不知道有多少次得到相同的答案。你帮了我很多。谢谢!:)@Charles为什么E_ALL
删除E_通知
?难道E_本身不包括一切,包括E_通知吗?“PHP6.0.0”?Heh:-)“对于纯开发@JohnMagnolia,请转到:error\u reporting=E\u ALL^E\u NOTICE^E\u WARNING
”是连接这三个选项的^
符号吗?如果是这样的话,E_ALL
是否已经包括E_通知
和E_警告
?“PHP6.0.0”?Heh:-)“对于纯开发@JohnMagnolia,请转到:error\u reporting=E\u ALL^E\u NOTICE^E\u WARNING
”是连接这三个选项的^
符号吗?如果是这样,E_ALL
是否已经包括E_通知
和E_警告
?显示错误=on有语法错误
有语法错误
。只有在我的服务器(IONOS)上对我有效的代码错误报告(-1)不应使用代码>。它可能不适用于所有系统。相反,应该是错误报告(E_ALL)代码>错误报告(-1)应该可以正常工作,正如这里的示例所示:ini\u集
的值实际上应该是字符串,例如ini\u集('display\u errors','1')代码>根据,并且在使用(例如,declare(strict_types=1);
仅在我的服务器(IONOS)错误报告(-1)上为我工作的代码时强制执行此操作不应使用代码>。它可能对e不起作用