Page 1 of 1
Help! Can't show errors
Posted: Fri Apr 02, 2010 3:58 pm
by MAtkins
Hi:
I'm an old VB, ASP, C# ASP.NET programmer who got fed up and decided to go w/ php.
I absolutely cannot get this thing to display syntax errors.
This is at the top of every page:
error_reporting(E_ALL);
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
Almost NEVER will it display an error.
I spend more time trying to find typos than anything else on this project.
Is there *any* way to display syntax errors or does php simply leave us in the dark?
Re: Help! Can't show errors
Posted: Fri Apr 02, 2010 5:00 pm
by requinix
First, by the time your script begins running PHP has already "started up". Not only can you not change the display_startup_errors setting in your code, if you could it would be too late to make any difference.
You have that code in the file with problems, correct?
Before your code executes PHP has to parse the file. As ini_set doesn't get any special treatment, PHP won't know that you want parse errors displayed when it finds them. Similarly error_reporting (as far as parse errors are concerned) won't do anything.
To show parse errors, you need to change display_errors and error_reporting before the buggy script can be loaded. That means
- in the main php.ini file
- in some additional INI files (though there generally aren't any)
- in a per-user php.ini (PHP as CGI) or with php_value in a .htaccess (PHP as an Apache module)
- in one file that includes or requires the buggy file (because PHP won't load the buggy file until after some code has executed)
Re: Help! Can't show errors
Posted: Sun Apr 04, 2010 9:30 am
by MAtkins
tasairis thanks.
Yes that makes all the sense in the World.
It's 'not' a compiled app.
I actually had php.ini open and almost did as you recommend.
For some reason I didn't think my way through that and left those vars off.
Thanks for the help:)
Re: Help! Can't show errors
Posted: Sun Apr 04, 2010 2:43 pm
by califdon
Thanks, tasairis, for a clear explanation of the PHP parsing process. We should make that a 'sticky' in this forum.
To MAtkins: most of us do without such error reporting, but it's a traumatic shock when you first come to PHP. The issue is that you must avoid doing that on your production server, because it's going to affect every script that runs in that directory (or on the entire site), which would not be nice if it's your production system!
Re: Help! Can't show errors
Posted: Sun Apr 04, 2010 3:05 pm
by MAtkins
Well, I hoped . . .
I changed the vars in the php.ini file.
I know it's the right php.ini file because I changed the default temp folder and that worked.
I stopped & restarted the IIS hoping that might be the problem.
I'm still getting just a blank page with most errors.
Is there any way to get it to tell me what is wrong?
Re: Help! Can't show errors
Posted: Sun Apr 04, 2010 3:26 pm
by MAtkins
I found this.
I had to set:
error_reporting = E_ALL
in the php.ini file
Thanks for your help:)