0

为客户在主机上工作。网站由 DreamHost 托管。index.php 文件功能齐全,但是从首页链接到的任何页面都显示为空白。我在可用的日志中找不到任何东西,所以一些搜索出现了以下代码:

error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);

我把它放在所有适用页面的 php 代码顶部,但是没有出现任何错误,页面仍然完全空白。我更像是一个安全人员而不是开发人员,所以有人能指出我正确的方向吗?

编辑:服务器 php.ini 文件也有 display_errors = 1 。

4

2 回答 2

1

检查您的代码中是否有@-operatordieexit。如果是,请输出一些字符串以了解您的脚本在哪里结束或使用error_log -function:

error_log("Oh no, file: ".__FILE__." on line ".__LINE__, 1, "operator@example.com");

在您的代码中包含以下错误处理程序,然后再试一次:

function exception_error_handler($errno, $errstr, $errfile, $errline )
{
  if (error_reporting() === 0)
  {
    return;
  }

  throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
}

set_error_handler("exception_error_handler");
于 2012-07-22T22:15:33.257 回答
0

您可以尝试error_log()在调用 index.php 的每个块之前/之后添加函数(if/else、for/foreach 或 while、函数或 $this->[*])。并继续进入从 index.php 调用的类文件 php,这样你就可以找到系统失败的地方。有时,php 系统不会打印任何错误日志,直到您打印(使用error_log()print_r()echo)问题附近的内容。

编辑

您可以通过命令行安装 php5-xdebug 和/或运行 index.php:

 php index.php

发现 php 错误系统和系统出现故障的位置将非常简单。

于 2012-07-22T22:13:03.600 回答