浏览器上没有PHP错误.什么配置对静默故障负责


No PHP errors on browser. what config is responsible for silent failure?

我试图在Amazon EC2上运行一个简单的PHP脚本。当我在浏览器上得到空白屏幕时,开始在步骤之间放置一些垃圾语法或echo。然后我发现脚本失败了,没有任何错误。

如何禁用静默故障?

<?php
putenv('HOME=/root');
echo 'after env'; //displayed on browser
require_once('/home/ec2-user/AWSSDKforPHP/sdk.class.php'); 
//i believe this require step was failed 
echo 'after require'; // not displayed on browser
$ec2 = new AmazonEC2();
$response = $ec2->describe_availability_zones();
print_r($response);
echo 'hello';
?>

这取决于您的php.ini设置,错误显示或错误报告可能会关闭。

添加到脚本的顶部:

ini_set('display_errors', 1);
error_reporting(E_ALL);

您可以使用Wesley Murch的相同答案

添加到脚本的顶部:

ini_set('display_errors', 1);
error_reporting(E_ALL);

上面你不需要做任何事情,只要刷新你的php页面。

或编辑php.ini文件在"/etc/php5/apache2/php.ini"然后添加或编辑

display_errors = On

如果你编辑php.ini文件,你需要重新启动apache。(有时它不工作,然后你应该使用第一个/local解决方案)

Ubuntu:

sudo service apache2 restart

尝试以下操作之一:

// Turn off all error reporting
error_reporting(0);
// Report simple running errors
error_reporting(E_ERROR | E_WARNING | E_PARSE);
// Reporting E_NOTICE can be good too (to report uninitialized
// variables or catch variable name misspellings ...)
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
// Report all errors except E_NOTICE
// This is the default value set in php.ini
    error_reporting(E_ALL ^ E_NOTICE); # this is what you might want to try using
// Report all PHP errors (see changelog)
error_reporting(E_ALL);
// Report all PHP errors
error_reporting(-1);
// Same as error_reporting(E_ALL);
ini_set('error_reporting', E_ALL);

我遇到了这个问题,并通过编辑/etc/php.ini到display_errors = On