View Full Version : Getting rid of php's error nagging

09-23-2004, 08:01 AM
I have a system where at one point, it will run a function in an if statement, and if the function fails, it will echo an explanation.

But on top of that, php will return it's info on the error (ynow, error line XX this, that, the other thing)

Is there a way I can stop it from printing the error report?

09-23-2004, 08:51 AM
Well the best way to combat this is to stop the error ocurring in the first place.

Like your parents, PHP only nags you for your own good , errors even when obfuscated use CPU to handle , examine your error and see if you can predict likely failures, e.g. with

function foo( $int ){
return 100 / $int ;
will throw an error if $int=0 (divsion by 0 error) , but this won't
function foo ( $int ){
if( is_int( $int ) && $int > 0 ){
return 100 / $int ;
return false ;

there are also times when an error might be expected;
<?echo mysql_num_rows( $res ) ;?>
$res may ne legitimately empty , so you can use '@' ,
<?echo @mysql_num_rows( $res );?>
which would supress the error.

you can also turn off error reporting at the head of your script (or in your php.ini)


but thats just hiding the errors , they ain't going away ;)