Error suppression

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Joshua Beall

    Error suppression

    Hi All,

    I know that I can prepend functions with an '@' character in order to get
    them to not output any errors, but I am wondering is there any way for a
    function that I write to know if it has been called with the '@' character?
    Then I can decide how errors are supposed to be handled. E.g., I could have
    them emailed or logged, instead of echoing them to the screen.

    Is this possible?

    -jb


  • Pedro Graca

    #2
    Re: Error suppression

    Joshua Beall wrote:[color=blue]
    > I know that I can prepend functions with an '@' character in order to get
    > them to not output any errors, but I am wondering is there any way for a
    > function that I write to know if it has been called with the '@' character?
    > Then I can decide how errors are supposed to be handled. E.g., I could have
    > them emailed or logged, instead of echoing them to the screen.
    >
    > Is this possible?[/color]

    Use the return value of the error_reporting ().

    <?php
    function user_function() {
    $err = error_reporting (E_ALL); // or simply error_reporting ()
    // to not change it but get the
    // the current value anyway
    if ($err == 0) {
    /* whatever, function was probably called with an '@' */
    }
    // rest of script
    error_reporting ($err);
    }
    ?>
    --
    --= my mail box only accepts =--
    --= Content-Type: text/plain =--
    --= Size below 10001 bytes =--

    Comment

    • auntie social

      #3
      Re: Error suppression

      On Tue, 03 Feb 2004 22:16:04 GMT, "Joshua Beall"
      <jbeall@donotsp am.remove.me.he raldic.us> wrote:
      [color=blue]
      >Hi All,
      >
      >I know that I can prepend functions with an '@' character in order to get
      >them to not output any errors, but I am wondering is there any way for a
      >function that I write to know if it has been called with the '@' character?
      >Then I can decide how errors are supposed to be handled. E.g., I could have
      >them emailed or logged, instead of echoing them to the screen.
      >
      >Is this possible?
      >
      > -jb
      >[/color]

      Placing the line:

      <?php error_reporting (0); ?>

      ....at the top of all of your pages (or, preferably, in an include file
      referenced by all pages) will turn error reporting off completely.
      Then you're free to put your own error-checking routines in (though
      you have to be careful, because if you miss a condition, it can be
      very difficult to debug problems).

      You can also use:

      <?php error_reporting (E_ALL); ?>

      ....during development to debug your code.

      More info is available from:



      Comment

      • Tim Van Wassenhove

        #4
        Re: Error suppression

        On 2004-02-03, Joshua Beall <jbeall@donotsp am.remove.me.he raldic.us> wrote:[color=blue]
        > Hi All,
        >
        > I know that I can prepend functions with an '@' character in order to get
        > them to not output any errors, but I am wondering is there any way for a
        > function that I write to know if it has been called with the '@' character?
        > Then I can decide how errors are supposed to be handled. E.g., I could have
        > them emailed or logged, instead of echoing them to the screen.[/color]

        http://www.php.net/manual -> Error handling and Logging Functions

        --

        Comment

        Working...