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 ();
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.
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:
Thanks for the post!
Did your message disappear? Read the Forums FAQ.
Spam Control | * indicates required field
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.
Copyright © 1996 - 2017. All Rights Reserved.