Connecting Tech Pros Worldwide Help | Site Map
 
 
LinkBack Thread Tools Search this Thread
  #1  
Old July 17th, 2005, 03:55 AM
Joshua Beall
Guest
 
Posts: n/a
Default 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





  #2  
Old July 17th, 2005, 03:55 AM
Pedro Graca
Guest
 
Posts: n/a
Default 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 =--
  #3  
Old July 17th, 2005, 03:56 AM
auntie social
Guest
 
Posts: n/a
Default Re: Error suppression

On Tue, 03 Feb 2004 22:16:04 GMT, "Joshua Beall"
<jbeall@donotspam.remove.me.heraldic.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:

http://www.php.net/error_reporting

  #4  
Old July 17th, 2005, 03:56 AM
Tim Van Wassenhove
Guest
 
Posts: n/a
Default Re: Error suppression

On 2004-02-03, Joshua Beall <jbeall@donotspam.remove.me.heraldic.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

--
http://home.mysth.be/~timvw
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 205,414 network members.