Syntax errors in classes fail to generate error messages

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
cpetercarter
Forum Contributor
Posts: 474
Joined: Sat Jul 25, 2009 2:00 am

Syntax errors in classes fail to generate error messages

Post by cpetercarter »

I have recently encountered a most puzzling problem.

I am working on the development of a CMS for podcasting. The initialisation script of my code switches full error reporting on, for obvious reasons. So whenever I make a silly syntax error, the script tells me about it, with one of php's wonderfully helpful error messages.

But if I make a syntax error inside a class, all I get is a blank screen - no error message. The problem relates only to parse errors - if there is a runtime problem, I get error messages in the normal way. I have adopted the policy of reloading and running the script after every tiny change so that I can quickly identify the problem when I get a blank screen. However, this is tedious, and if anyone has any thoughts on why I am not getting normal error messages and what I can do about it, I would be pleased to know.
User avatar
Jade
Forum Regular
Posts: 908
Joined: Sun Dec 29, 2002 5:40 pm
Location: VA

Re: Syntax errors in classes fail to generate error messages

Post by Jade »

Do you have error reporting turned on in your .ini file or at the top of the page? If you're putting the error_reporting(E_ALL); at the top of the page try putting it in the class files too.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: Syntax errors in classes fail to generate error messages

Post by Weirdan »

This usually indicates that you're using shut-up operator (@) on the require() / include() call.
cpetercarter
Forum Contributor
Posts: 474
Joined: Sat Jul 25, 2009 2:00 am

Re: Syntax errors in classes fail to generate error messages

Post by cpetercarter »

Thanks. I have identified the problem as a "@" in the __autoload() function. I must have put it there months ago, thinking that it would suppress error messages if the file did not exist, and forgetting that it would also suppress messages about parse errors in the included file.
Post Reply