TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 06-29-2008, 04:11 PM   #1 (permalink)
The Contributor
 
Ross's Avatar
 
Join Date: Jan 2008
Location: England, UK
Posts: 83
Thanks: 3
Ross is on a distinguished road
Default Muting errors in PHP5

My bad - I missed my missing semicolon :P

Just come across something very confusing. In PHP4 we could mute errors caused by a function by using @function().

I'm using PHP5 on this server and I get:

Quote:
Parse error: syntax error, unexpected '@' in /home/sites/***.co.uk/public_html/***/includes/class_registry.php on line 25
Lines 24-25:
PHP Code:
$config_file DIR '/includes/config/configuration.php'
@require_once($config_file); 
Now I'd assume PHP would throw an error notifying this doesn't work - I have errors set to E_ALL - rather than a parse error and I can't find anything on php.net - any ideas?
Ross is offline  
Reply With Quote
Old 06-29-2008, 08:18 PM   #2 (permalink)
The Visitor
 
Join Date: Jun 2008
Location: Zagreb, Croatia
Posts: 4
Thanks: 3
mfolnovich is on a distinguished road
Default

for me it works ...
try with include_once($config_file); ...
Send a message via ICQ to mfolnovich Send a message via AIM to mfolnovich Send a message via MSN to mfolnovich Send a message via Yahoo to mfolnovich
mfolnovich is offline  
Reply With Quote
Old 06-29-2008, 10:30 PM   #3 (permalink)
The Frequenter
Newcomer 
 
xenon's Avatar
 
Join Date: Dec 2007
Location: Bucharest, Romania
Posts: 438
Thanks: 3
xenon is on a distinguished road
Default

Yes, you did miss your semicolon However, this thing you're doing it's not called 'error muting', it's called error suppression. What's really happening is this: the error is still thrown in the back, except it's not shown to you. That's why this is bad and you should rather use error_reporting to control when and what errors to show. Oh, and because it's global. You don't have to set error_reporting before any statement, you just put it in the beginning of the script and that's it. You can, however set error reporting to a certain level until some point of your script, then change its value (turn it on/off depending on the case). Not the case with error suppression, where the @ must be in front of EVERY statement that throws some kind of error/notice/warning.
__________________
I have optimistic thoughts, even though sometimes (if not always) life's a bitch.
xenon is offline  
Reply With Quote
The Following User Says Thank You to xenon For This Useful Post:
Ross (06-30-2008)
Old 06-30-2008, 08:12 AM   #4 (permalink)
The Contributor
 
Ross's Avatar
 
Join Date: Jan 2008
Location: England, UK
Posts: 83
Thanks: 3
Ross is on a distinguished road
Default

Quote:
Originally Posted by xenon View Post
Yes, you did miss your semicolon However, this thing you're doing it's not called 'error muting', it's called error suppression. What's really happening is this: the error is still thrown in the back, except it's not shown to you. That's why this is bad and you should rather use error_reporting to control when and what errors to show. Oh, and because it's global. You don't have to set error_reporting before any statement, you just put it in the beginning of the script and that's it. You can, however set error reporting to a certain level until some point of your script, then change its value (turn it on/off depending on the case). Not the case with error suppression, where the @ must be in front of EVERY statement that throws some kind of error/notice/warning.
Thanks for your reply. So supposing I didn't want to display any PHP errors on a production system (obviously) - I could use errr_reporting(E_ALL) to show them to logged in Administrators?

Thanks for this - didn't realise I was following a bad practise!
Ross is offline  
Reply With Quote
Old 06-30-2008, 03:13 PM   #5 (permalink)
The Acquainted
 
drewbee's Avatar
 
Join Date: May 2008
Posts: 175
Thanks: 9
drewbee is on a distinguished road
Default

Quote:
Originally Posted by redSHIFT View Post
Thanks for your reply. So supposing I didn't want to display any PHP errors on a production system (obviously) - I could use errr_reporting(E_ALL) to show them to logged in Administrators?

Thanks for this - didn't realise I was following a bad practise!

Personally... I turn error reporting completely off for production systems. Error reporting should be used for development purposes, then if anything should go amiss properly capture the error and display a generic 'error has occured' page.

Although only turning it on for administrators and not general users is a better idea then jut turning it on for everyone. Hackers and malicious users tend to look for these error messages to give them clues.
__________________
There are No Stupid Questions. But there a LOT of Inquisitive Idiots.
Send a message via AIM to drewbee
drewbee is offline  
Reply With Quote
The Following User Says Thank You to drewbee For This Useful Post:
Ross (06-30-2008)
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 12:02 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design