Hiding php warning 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
srirams
Forum Commoner
Posts: 36
Joined: Wed May 25, 2005 8:57 am
Location: India
Contact:

Hiding php warning messages

Post 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.
djot
Forum Contributor
Posts: 313
Joined: Wed Jan 14, 2004 10:21 am
Location: planet earth
Contact:

Post by djot »

-
Put this inside your script:

Code: Select all

<?php
error_reporting(E_ERROR|E_PARSE);
//...your code...
?>
djot
-
User avatar
senthilnayagam
Forum Newbie
Posts: 17
Joined: Wed Jun 08, 2005 5:36 am
Location: Bangalore

error reporting

Post 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
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post 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 = ..
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

Ya, I'd fix the warning - what's the warning about?
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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 ;)
Post Reply