<h3>什么都没看见。这一页是空的和白色的。</h3>
<p>也被称为<em>死亡白页</em>或<em>死亡白屏</em>。当错误报告关闭并且发生致命错误(通常是语法错误)时,就会发生这种情况。</p>
<p>如果启用了错误日志记录,则会在错误日志中找到具体的错误消息。这通常位于名为“php_errors.log”的文件中,或者位于中心位置(例如许多Linux环境中的<code>/var/log/apache2</code>),或者位于脚本本身的目录中(有时在共享宿主环境中使用)。</p>
<p>有时,临时启用错误显示可能更简单。然后,白色页面将显示错误消息。小心,因为这些错误对每个访问网站的人都是可见的。</p>
<p>这可以通过在脚本顶部添加以下PHP代码来轻松完成:</p>
<pre><code>ini_set('display_errors', 1); error_reporting(~0);
</code></pre>
<p>代码将打开错误显示并将报告设置为最高级别。</p>
<p>因为<a href="http://php.net/ini_set" rel="noreferrer">^{<cd2>}</a>是在运行时执行的,所以它对解析/语法错误没有影响。这些错误将出现在日志中。如果还想在输出中显示它们(例如在浏览器中),则必须将<a href="http://php.net/display_startup_errors" rel="noreferrer">^{<cd3>}</a>指令设置为<code>true</code>。在<code>php.ini</code>或<code>.htaccess</code>或<a href="http://docs.php.net/configuration.changes" rel="noreferrer">any other method that affects the configuration <em>before</em> runtime</a>中执行此操作。</p>
<p>您可以使用相同的方法设置<a href="http://php.net/manual/pt_BR/errorfunc.configuration.php#ini.log-errors" rel="noreferrer">log_errors</a>和<a href="http://php.net/manual/pt_BR/errorfunc.configuration.php#ini.error-log" rel="noreferrer">error_log</a>指令来选择您自己的日志文件位置。</p>
<p>查看日志或使用显示,您将得到更好的错误消息和脚本停止的代码行。</p>
<p>相关问题:</p>
<ul>
<li><a href="https://stackoverflow.com/questions/1475297/phps-white-screen-of-death">PHP's white screen of death</a></li>
<li><a href="https://stackoverflow.com/questions/2914127/white-screen-of-death">White screen of death!</a></li>
<li><a href="https://stackoverflow.com/questions/5680831/php-5-3-does-not-display-error-messages">PHP Does Not Display Error Messages</a></li>
<li><a href="https://stackoverflow.com/q/3075355/367456">PHP emitting 500 on errors - where is this documented?</a></li>
<li><a href="https://stackoverflow.com/questions/845021/how-to-get-useful-error-messages-in-php">How to get useful error messages in PHP?</a></li>
<li><a href="https://stackoverflow.com/search?q=%5Bphp%5D+White+Page+Screen+Of+Death">All PHP "White Page of Death" Questions on Stackoverflow</a></li>
</ul>
<p>相关错误:</p>
<ul>
<li><a href="https://stackoverflow.com/questions/12769982/reference-what-does-this-error-mean-in-php/12770089/#12770089">Parse error: syntax error, unexpected T_XXX</a></li>
<li><a href="https://stackoverflow.com/questions/12769982/reference-what-does-this-error-mean-in-php/12769983#12769983">Fatal error: Call to a member function ... on a non-object</a></li>
<li><a href="https://stackoverflow.com/a/24423272/476">Code doesn't run/what looks like parts of my PHP code are output</a></li>
</ul>