I have installed xampp on ubuntu. PHP is configured to show all possible errors, warnings, notices etc, but when i make an error in php code no error is displayed.
When i copy that file to other computer (debian with native apache, mysql and php set) and open it in browser it shows
Fatal error: Call to a member function fetch() on a non-object in...
as expected, so why xampp with identical php.ini shows just an empty page?
Another solution is
add this line in your .htaccess file
php_value display_errors on
there may be some serever configure mistake
write below as first line at your php page
ini_set('error_reporting', E_ALL);
ini_set( 'display_errors', 1 );
NOTE: use Xdebug
Find your php.ini file. You can find the location by typing php --ini in the terminal.
Then look for display_errors and set it to 1. And error_reporting to E_ALL.
This will set the value globally.
If you only need to see errors for a particular script or application:
error_reporting( E_ALL );
ini_set( 'display_errors', 1 );
http://php.net/manual/en/function.error-reporting.php
http://php.net/manual/en/errorfunc.configuration.php
Related
I get a blank white page when running a script that I'm migrating from a Linux Apache server to IIS.
Following advice elsewhere on SO, I checked that the correct php.ini is being loaded. From phpinfo():
Loaded Configuration File C:\php\php.ini
In that php.ini file, I have the following:
error_reporting = E_ALL
display_errors = On
log_errors = On
error_log = "C:\Windows\Temp\php_errors.log"
For good measure, I have also added
ini_set( 'display_errors', 1 );
error_reporting(E_ALL);
in the script itself.
I'm getting no errors output to the screen, and the file C:\Windows\Temp\php_errors.log doesn't exist.
I'm obviously missing something; what is it? :)
I recently upgraded to PHP 5.3.22 and now I'm getting WSODs whenever there are errors in my php code. I know I have display_errors disabled in php.ini, so I tried adding the following code to the top of my scripts to temporarily enable displaying errors on the screen for debugging.
error_reporting(E_ALL);
ini_set('display_errors', '1');
The above works if I have an undefined function but if I miss a semi-colon at the end of a line, it still displays a WSOD.
How can I get all errors to display on screen when I'm developing the scripts?
Enabling error reporting at run time like that fails to show fatals. You can enable it in your php.ini or add this to your htaccess to override it:
php_value display_errors 1
As the file cannot be parsed, setting the error level and display_errors inside the file is having no effect.
Set it in your php.ini
previously i had php5.1 installed and i recently upgraded to php5.3.
In previous versions all syntax errors and other errors were display in page whenever error occurs and it was easy for me to debug.
But now whenever there is error in page it just stops processing and shows blank.
i tried adding following too:
error_reporting(E_ALL & E_STRICT);
ini_set('display_errors', 1);
at top of page but didn't work. Any suggestions?
Edit more info:
when i do phpinfo(), it shows my configuration file: c:\php\php.ini.
Further on opening and editing php.ini file i found:
error_reporting = E_ALL
display_errors = On
Edit More Info:
Corrected error_reporting to E_ALL | E_STRICT.
Found it almost blanks out whenever the error is being generated from code inside function or class.
try this.
ini_set('display_errors','On');
whenever there is error in page
What level of error? Is it fatal or not?
If fatal - then your in-code settings (error_reporting() and ini_set) are not used at all: php.ini ones are used instead.
IMO, you've provided insufficient info: at least php.ini values you have for error_reporting and error_log directives needed.
I have a WAMP 2.2 server running on a Windows 7 box and cannot get PHP error logging working at all.
The file is always blank even after I explicitly trigger USER_ERROR errors, or cause normal ERROR errors.
I'm including the error relevant sections of the php.ini file - hopefully you can find something:
error_reporting = E_ALL
error_log = "c:/wamp32/logs/php_error.log" ;(UNCOMMENTED BY ME)
log_errors = On
display_errors = On
The line ; log_errors is just a comment for the following block, for the purpose of showing you what the settings are in dev vs production. You uncommented four lines which aren't meant to control anything, and I'm surprised your Apache service doesn't have problems starting up because of it.
What you need to do is look for the line:
log_errors = Off
And change the value to On
That said, once you restart the Apache service, the settings should take effect. However, I was unable to get WampServer to properly log php errors despite these settings. Apache will not start up when I specify the error_log parameter.
For me it turned out to be a permissions error. I ended up giving EVERYONE full control of the error log file and it seemed to fix my issue. Best of luck.
Did you try adding these lines to your php file?
ini_set("display_errors", "1");
ini_set("log_errors", "1");
ini_set("error_log", "/wamp64/logs/php_error.log");
I want PHP to display parse errors on screen. What I get instead is a blank page. Nothing gets written to server's error log file.
My setup: PHP5.2.9/IIS 6 (not Apache!).
My PHP.INI:
error_reporting=E_STRICT
display_errors = On
display_startup_errors = On
log_errors = On
error_log = "C:\Program Files\Zend\ZendServer\logs\php_error.log"
How do I get parse or fatal errors to be either logged or shown on screen?
Thanks,
Temuri
UPDATE: After playing with different switches it looks to be an IIS specific problem. ANY IDEAS FOLKS?
Setting error level in php file itself does not resolve the problem here because the file itself cannot be parsed !!
You need to change error_reporting line in your php.ini as follows:
error_reporting = E_ALL
BTW: There are some examples in php.ini file about what to do to display which type of error messages.
Good luck,
mcemoz
Apache doesn't always like to report parsing errors either. From the command line, run
php -l <file>
The -l switch tells PHP to check file syntax. See the man page.
E_STRICT is not included in E_ALL (until PHP 6). If you want to keep getting E_STRICT
In php.ini:
error_reporting = E_ALL | E_STRICT
At runtime:
error_reporting( E_ALL | E_STRICT );
You'll need to set the error reporting level (and display_errors) in php.ini to see syntax errors. If PHP encounters a syntax error, the runtime doesn't get executed, so setting at runtime won't work. (See the display_errors link.)
You can verify the script syntax with this command in terminal:
php -l path/to/file.php
Personally, I added this line to my ~/.bash_profile file so I can easily run php -l on all files in the current working directory:
phpl() { for i in *.php; do php -l $i; done }
If you're really hardcore, you can even run your app from the command line. You'll have a much better chance of seeing compile-time errors, and it's just kinda cool.
You can use the $argv variable to get the first argument, $argv[1], then use that as the request.
<?php
// show those errors!
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', 1);
// simulate a web server request
$request = '/' . isset($argv[1]) ? ltrim($argv[1], '/') : '/';
$_SERVER['PATH_INFO'] = $_SERVER['REQUEST_URI'] = $request;
Then you can run your script via command line. This would be the equivalent of visiting:
your-webapp.com/request/uri/here
php /path/to/script.php request/uri/here
Here is a more comprehensive example for running CodeIgniter via command line. It should work for many other frameworks too: http://phpstarter.net/2008/12/run-codeigniter-from-the-command-line-ssh/
As Rasmus Lerdorf suggests, always use error_reporting(-1) on development server.
Re: Blank screen of php death death, I discovered that setting
php_value error_reporting "E_ALL" or
php_value error_reporting 8192
in .htaccess on my Windows 7, Wampserver w/ apache 2.2.4 and php 5.3.13 are sure ways to get the blank php error screen -- today, June 3, 2014. These htaccess lines DO set the desires value in phpinfo(), but the display of the errors happens only when the line is commented out (not used) in htaccess.
BUT... the next minute I discover that
php_value error_reporting 8191
DOES set the phpinfo() value AND also allows display of the error messages to the browser! D'oh! It must be an integer and also apparently a particular or valid integer, and not just a large enough integer!
If you're using Zend Framework (v1) and you're using the Autoloader, the following code will prevent parse errors from being displayed:
self::$Autoloader->suppressNotFoundWarnings(true);
See the following answer for more details:
Display php errors when using Zend framework
Try this.
error_reporting(E_ALL);
ini_set("display_errors", 1);