Hello and welcome to our community! Is this your first visit?
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
    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
    Perth Australia
    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 ){
    100 $int ;
    will throw an error if $int=0 (divsion by 0 error) , but  this won't
    function foo $int ){
    is_int$int ) && $int ){
    100 $int ;
    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
    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