Page 1 of 1

Hiding php warning messages

Posted: Mon Jun 27, 2005 1:16 pm
by srirams
All,

Is there a way by which we can hide the warningmessages from being displayed on the web browser?
My code actually works but throws a warning message at the begining which I want to remove.

Posted: Mon Jun 27, 2005 1:24 pm
by djot
-
Put this inside your script:

Code: Select all

<?php
error_reporting(E_ERROR|E_PARSE);
//...your code...
?>
djot
-

error reporting

Posted: Mon Jun 27, 2005 1:29 pm
by senthilnayagam
Hi sriram,

that stuff is called error reporting learn more on the php manual link given below

http://www.php.net/error_reporting


you can put this in the beginning lines of your code, and voila all errors are gone

Code: Select all

// Turn off all error reporting
error_reporting(0);
but be careful, if you have parse-errors(also some times called compiler errors) you will not get any output, sometimes if you are behind a proxy(especially squid) the error will show up as "Zero Sized Reply"


in the manual more info is given on enabling and disabling error with error handlers which is a advanced and sometimes a very useful feature for professional programmers


regards
Senthilnayagam

Posted: Mon Jun 27, 2005 1:46 pm
by John Cartwright
Why not just fix your warning?
You can also supress errors/warning by adding a @ before the function name.

Ie. @file_get_contents = ..

Posted: Mon Jun 27, 2005 2:35 pm
by pickle
Ya, I'd fix the warning - what's the warning about?

Posted: Mon Jun 27, 2005 3:28 pm
by Chris Corbyn
Uh huh... I do all coding with E_ALL errors... no wonky stuff that way..

Post your code.. I'm sure it's trivial and probably useful to learn ;)