Here is my simple codes file in /var/www/read.php :
error_reporting(E_ALL);
<?php
echo hello"
?>
I ran across the error reporting when to run `php /var/www/read.php ' on debian console.
PHP Parse error: syntax error, unexpected '"', expecting ',' or ';' in /var/www/read.php on line 3
But there is no error reporting in web page when to input 127.0.0.1/read.php
in firefox.
I have set the values in php.ini as following:
error_reporting = E_ALL & ~E_NOTICE
display_errors = On
It is no use for me to restart apache2 with command :
service apache2 restart
Here is my phpinfo message. It is no use to add two lines in my read.php file,no error message reported in my firefox.How can i fix it?My system is debian7+php .
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);
echo hello"
?>
find / -name 'php.ini'
/etc/php5/apache2/php.ini
/etc/php5/cli/php.ini
The problem solved according to PHP doesn't show any kind of errors
First, the error_reporting()
function should be moved inside the <?php ?>
tags.
There are usually two php.ini files in a typical setup (One used by the webserver, other one used by the command line).
On a unix distribution, it is usually located somewhere below the /etc/php
folder, like that for example /etc/php/apache2/php.ini
.
To be sure what configuration file is loaded for PHP by the webserver, do a simple phpinfo();
in a webpage and just search for configuration file
.
If you modify the one used by your websever, make sure to restart Apache afterwards, so it loads the new configuration.
If you want to enforce programmatically setting, you can use the ini_set
function.
In your case, if you want to see any error on the page.
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);
foobar();
Update :
Adding ini_set('display_errors', 1);
won't do anything if there is a syntax error in the page, because the syntax error is thrown before the execution of the script. Try to create another type of error, e.g. call an unknown function instead, and you should see it.
Use error_reporting(1);
or error_reporting(TRUE);
and make sure no where you have disabled anything pertaining to error reporting
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With