P K
P K

Reputation: 10210

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

I was trying to run a simple PHP script on Amazon EC2. As i got blank screen on the browser, started putting some garbage syntax or echo in between steps. Then i figured out that script was failing without any error.

How to disable silent failure?

<?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';

?>

Upvotes: 0

Views: 860

Answers (4)

user3708590
user3708590

Reputation: 31

You can use the same answer from Wesley Murch

Add this to the top of your script:

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

Above you don't need to do anything, just refresh your php page.

or edit the php.ini file at "/etc/php5/apache2/php.ini" and add or edit the line

display_errors = On

If you edit the php.ini file, you will need to restart apache. (sometimes it doesn't work, and then you should use the first/local solution)

Ubuntu:

sudo service apache2 restart

I hope it works.

Upvotes: 3

Tom Kincaid
Tom Kincaid

Reputation: 4975

I had this problem and fixed it by editing /etc/php.ini to display_errors = On

Upvotes: 0

Nonym
Nonym

Reputation: 6299

Try one of the following:

// 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);

Upvotes: 2

No Results Found
No Results Found

Reputation: 102834

It can depend on your php.ini settings, error display or error reporting might be off.

Add this to the top of your script:

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

Upvotes: 7

Related Questions