虚拟化容器,大数据,DBA,中间件,监控。

php页面出现空白页面该怎么办

01 11月
作者:admin|分类:应用管理
php页面出现空白页面该怎么办

在使用 PHP 程序的过程中,我们经常会碰到页面出现空白,页面出现空白是因为程序运行过程中遇到问题不能正常执行,而 PHP 环境配置信息又阻止向页面输出 PHP 返回的错误信息,遇到这样的问题不要惊慌,只要打开PHP的报错信息,然后根据错误信息提示就能找到问题的原因,然后逐步解决。

下面介绍如何在程序中设置PHP的报错级别:

我们在程序运行的开始利用 error_reporting()函数设置 PHP 的报错级别并返回当前级别。

    CODE: [COPY]
  • <p>error_reporting(report_level);</p></pre><pre><p>如果参数 level 未指定,当前报错级别将被返回。下面几项是 level 可能的值:</p><p>值     常量               描述</p><p>1     E_ERROR     Fatal run-time errorsErrors that can not be recovered fromExecution of the script is halted</p><p>2     E_WARNING     Non-fatal run-time errorsExecution of the script is not halted</p><p>4     E_PARSE     Compile-time parse errorsParse errors should only be generated by the parser</p><p>8     E_NOTICE     Run-time noticesThe script found something that might be an errorbut could also happen when running a script normally</p><p>16     E_CORE_ERROR     Fatal errors at PHP startupThis is like an E_ERROR in the PHP core</p><p>32     E_CORE_WARNING     Non-fatal errors at PHP startupThis is like an E_WARNING in the PHP core</p><p>64     E_COMPILE_ERROR     Fatal compile-time errorsThis is like an E_ERROR generated by the Zend Scripting Engine</p><p>128     E_COMPILE_WARNING     Non-fatal compile-time errorsThis is like an E_WARNING generated by the Zend Scripting Engine</p><p>256     E_USER_ERROR     Fatal user-generated errorThis is like an E_ERROR set by the programmer using the PHP function trigger_error()</p><p>512     E_USER_WARNING     Non-fatal user-generated warningThis is like an E_WARNING set by the programmer using the PHP function trigger_error()</p><p>1024     E_USER_NOTICE     User-generated noticeThis is like an E_NOTICE set by the programmer using the PHP function trigger_error()</p><p>2048     E_STRICT     Run-time noticesPHP suggest changes to your code to help interoperability and compatibility of the code</p><p>4096     E_RECOVERABLE_ERROR     Catchable fatal errorThis is like an E_ERROR but can be caught by a user defined handle (see also set_error_handler())</p><p>8191     E_ALL     All errors and warningsexcept level E_STRICT (E_STRICT will be part of E_ALL as of PHP 6.0)</p></pre><p>例子:</p><pre><p>任意数目的以上选项都可以用“或”来连接(用 OR 或 |),这样可以报告所有需要的各级别错误。例如,下面的代码关闭了用户自定义的错误和警告,执行了某些操作,然后恢复到原始的报错级别:</p><p></p><p>//禁用错误报告</p><p>error_reporting(0);</p><p>//报告运行时错误</p><p>error_reporting(E_ERROR | E_WARNING | E_PARSE);</p><p>//报告所有错误</p><p>error_reporting(E_ALL);</p><p></p>

浏览2879 评论0
返回
目录
返回
首页
User %s already has more than \'max_user_connections\' active connections 如何让php显示错误信息