Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jan 2004
    Posts
    107
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Getting rid of php's error nagging

    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?

  • #2
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,108
    Thanks
    11
    Thanked 101 Times in 99 Posts
    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

    PHP Code:
    <?
    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 ){
           return 
    100 $int ;
        }else{
          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)

    <?error_reporting(0);?>

    but thats just hiding the errors , they ain't going away
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •