Cynosure.X International

:

Add Comment | Related Links | TrackBack
Related Content

Turn Off Warning/Error Reporting Temporary in PHP

Sometimes, your server side scripts performs operation that are not guaranteed to succeed all the time. For example, connection to another remote service. When the operation fails, PHP provides a warning or a error message. But that message is shown to the web user and may contain sensitive information that you don't want your visitor to see. The trick to prevent leaking sensitive information in this situation is to temporarily turn off the warning and error messages. Following is an example of how to do it:

$cerl = error_reporting ();
error_reporting (0);
. . .
sensitive operation go here.
. . .
error_reporting ($cerl);

The first line asks for the current error reporting level and stores it. The second line disables all warning and error display. Finally, the last line sets the error reporting level back to the way it is.

Chieh Cheng
Sun, 11 Dec 2011 10:03:27 +0000

I just learned about the error_reporting function today, since it helped me remove a harmless warning that was showing up on a website. Also learned about the "@" operator. Good source of info right here on this topic:

http://www.programmerinterview.com/index.php/php-questions/h . . .

Thanks for the post!

Tony
Sat, 08 Dec 2012 14:51:18 +0300

Add Comment | Related Links | TrackBack
Related Content

Did your message disappear? Read the Forums FAQ.

Add Comment

Spam Control | * indicates required field
Your Name: *
E-mail:
Remember Me!
Comment: *
File attachment is optional. Please do not attach a file to your submission unless it is relevent.
Attach File:
(2 MB Max)
Spam Protection: * Sum of 3 + 3?
Click button only once, please!

TrackBack

Send Ping | TrackBack URL | Spam Control

No TrackBacks yet. TrackBack can be used to link this thread to your weblog, or link your weblog to this thread. In addition, TrackBack can be used as a form of remote commenting. Rather than posting the comment directly on this thread, you can posts it on your own weblog. Then have your weblog sends a TrackBack ping to the TrackBack URL, so that your post would show up here.

Messages, files, and images copyright by respective owners.

Products | Services
Forums | Latest | RSS
Library | Search | Wiki
Help | Licenses

Login | Register

15 Users Online

Hacking Digital Cameras
Fun for Photographers


Amazon Associate

Copyright © 1996 - 2014. All Rights Reserved.