Re: [PHP] set_error_handler() only triggering every Nth time

2012-03-22 Thread Robert Cummings

On 12-03-22 03:57 PM, Daevid Vincent wrote:

Resending since I didn't get a single reply. Maybe it got lost?

-Original Message-
Sent: Tuesday, March 13, 2012 5:58 PM

I am implementing a custom error handler and started noticing some bizarre
behavior. Every Nth time I refresh the page, I see the error/output.


Have you tried sending headers that disable caching?

Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] set_error_handler help

2008-05-02 Thread Richard Heyes

Is there any way to use a class to handle errors? I've tried some stuff like
set_error_handler(Error_Handler::logError and such, but with no luck.


It accepts a callback type, which is a pseudo type. Basically an array 
containg the object and the method to use. Eg.


$obj = new ErrorHandlingObject();
set_error_handler(array($obj, 'myMethod'));

--
Richard Heyes

++
| Access SSH with a Windows mapped drive |
|http://www.phpguru.org/sftpdrive|
++

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] set_error_handler help

2008-05-02 Thread Craige Leeder
I beleive you can also do

set_error_handler(array('classname', 'myMethod'));

for static methods.

- Craige
On Fri, May 2, 2008 at 2:26 PM, Richard Heyes [EMAIL PROTECTED] wrote:

  Is there any way to use a class to handle errors? I've tried some stuff
 like
  set_error_handler(Error_Handler::logError and such, but with no luck.
 

  It accepts a callback type, which is a pseudo type. Basically an array
 containg the object and the method to use. Eg.

  $obj = new ErrorHandlingObject();
  set_error_handler(array($obj, 'myMethod'));

  --
  Richard Heyes

  ++
  | Access SSH with a Windows mapped drive |
  |http://www.phpguru.org/sftpdrive|
  ++

  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] set_error_handler() fails

2006-05-06 Thread Richard Lynch
On Fri, May 5, 2006 6:20 am, icy wrote:
 chris smith wrote:

 What does your code look like?

 I just realized that when called a second time, set_error_handler()
 returns my custom error handler but it is never triggered.
 Code looks like this:

 ?php
   if (set_error_handler('core_error_handler', E_ALL) === NULL)

I'm not sure E_ALL is kosher there, since E_ALL include E_ERROR, and
E_ERROR can't be caught by an error handler...

Try doing it without the E_ALL, since it's going to catch everything
it can by default anyway.
-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] set_error_handler() fails

2006-05-06 Thread Richard Lynch
On Fri, May 5, 2006 8:08 am, Martin Alterisio \El Hombre Gris\ wrote:
 And set_error_handler() returns NULL because there isn't a previously
 defined error handler, not because it failed.

Since it's documented to return NULL when it fails to set the error
handler, one would hope it does NOT return NULL if there was no
previously-defined error handler...  That would be bad.

You'd never be able to distinguish between the error condition NULL
and the no previous handler NULL. :-(

It probably returns FALSE, 0, or '' in that case, though the docs are
imprecise on that very point...  That may also have changed in
different versions of PHP as set_error_handler pre-dates TRUE/FALSE
values for a true BOOL datatype...

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] set_error_handler() fails

2006-05-05 Thread icy

Richard Lynch wrote:

It's possible that you have mistaken whatever set_error_handler
returns for no previous error handler for NULL...

Are you using === NULL or is_null() to test?

If not, I suspect it's really returning FALSE or '' and what you think
is an error condition is, in fact, not an error condition at all.



I use === NULL, so it really returns NULL.
My own error handler is never called so this is another indication that 
it fails. PHP doesn't throw any error or exception. I also searched for 
an entry in php.ini which might turn own error handlers off but didn't 
find anything relevant. Maybe someone can reproduce the bug.

This issue is freaking me out.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] set_error_handler() fails

2006-05-05 Thread chris smith

On 5/5/06, icy [EMAIL PROTECTED] wrote:

Richard Lynch wrote:
 It's possible that you have mistaken whatever set_error_handler
 returns for no previous error handler for NULL...

 Are you using === NULL or is_null() to test?

 If not, I suspect it's really returning FALSE or '' and what you think
 is an error condition is, in fact, not an error condition at all.


I use === NULL, so it really returns NULL.
My own error handler is never called so this is another indication that
it fails. PHP doesn't throw any error or exception. I also searched for
an entry in php.ini which might turn own error handlers off but didn't
find anything relevant. Maybe someone can reproduce the bug.
This issue is freaking me out.


What does your code look like?

--
Postgresql  php tutorials
http://www.designmagick.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] set_error_handler() fails

2006-05-05 Thread icy

chris smith wrote:


What does your code look like?


I just realized that when called a second time, set_error_handler() 
returns my custom error handler but it is never triggered.

Code looks like this:

?php
if (set_error_handler('core_error_handler', E_ALL) === NULL)
echo 'could not set error handlerbr /';

trigger_error('test error');

var_dump(set_error_handler('core_error_handler', E_ALL));

function core_error_handler($errno, $errstr, $errfile, $errline)
{
echo 'error...';
}
?

This gives me the following output:

could not set error handler
Notice: test error in /var/www/.../core.inc.php on line 5
core_error_handler

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] set_error_handler() fails

2006-05-05 Thread Martin Alterisio \El Hombre Gris\

icy escribió:

chris smith wrote:


What does your code look like?


I just realized that when called a second time, set_error_handler() 
returns my custom error handler but it is never triggered.

Code looks like this:

?php
if (set_error_handler('core_error_handler', E_ALL) === NULL)
echo 'could not set error handlerbr /';

trigger_error('test error');

var_dump(set_error_handler('core_error_handler', E_ALL));

function core_error_handler($errno, $errstr, $errfile, $errline)
{
echo 'error...';
}
?

This gives me the following output:

could not set error handler
Notice: test error in /var/www/.../core.inc.php on line 5
core_error_handler

Have you thought about the fact that you're pointing to a function 
that's not been defined yet when the error is triggered?


And set_error_handler() returns NULL because there isn't a previously 
defined error handler, not because it failed.


Hope this helps.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] set_error_handler() fails

2006-05-04 Thread Richard Lynch
On Thu, May 4, 2006 4:19 pm, icy wrote:
 I use set_error_handler() in my script but it fails and returns NULL
 indicating an error has happened.
 But there are no entries in error.log ore something similar.
 How can I find out what actually went wrong?

It's possible that you have mistaken whatever set_error_handler
returns for no previous error handler for NULL...

Are you using === NULL or is_null() to test?

If not, I suspect it's really returning FALSE or '' and what you think
is an error condition is, in fact, not an error condition at all.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] set_error_handler always returns false

2003-06-23 Thread Lars Torben Wilson
On Mon, 2003-06-23 at 15:12, Jeff Stewart wrote:
 I'm using PHP 4.3.1 as an Apache module.  No matter what I try, I can't get
 set_error_handler() to do anything other than return false.  Under what
 circumstances does this happen?
 
 ?php
 function doobee($errno, $errstr, $errfile, $errline, $errcontext) {
  echo Handled.;
 }

 $retval = true;
 if (($retval = set_error_handler(doobee)) == false) echo Didn't work.;
 // echos every time
 ?


Note that it's not necessarily returning false here; it could be 0, or
the empty string, or an empty array...use the '===' operator to test
whether two operands are of the same type and evaluate to the same
value.

   http://www.php.net/manual/en/language.operators.comparison.php

Noting from the manual that set_error_handler() returns FALSE on error,
or the name of the previously defined error handler (if there was one)
on success, I am thinking it's probably just returning the empty
string--you likely didn't have an error handler set up before.

   http://www.php.net/set_error_handler

So replace your '==' with '===' and you should be good to go.


Hope this helps,

Torben

 --
 Jeff S.

-- 
 Torben Wilson [EMAIL PROTECTED]+1.604.709.0506
 http://www.thebuttlesschaps.com  http://www.inflatableeye.com
 http://www.hybrid17.com  http://www.themainonmain.com
 - Boycott Starbucks!  http://www.haidabuckscafe.com -




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] set_error_handler inside a class

2003-01-28 Thread John W. Holmes
 hi guys how is ti possible to do a set_error_handler within a class so
it
 will trigger the callback function and so will be able to return the
line
 and file in the message ?

You'd set it just like you would anywhere else in your code. 

If you want the callback function to be a method in your class, then you
pass an array to set_error_handler(). Details are in the manual on the
format of the array. It'll be the same as any other callback function
that you can send a classes method to.

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] set_error_handler inside a class

2003-01-28 Thread Dan Rossi
sorry is there a way to do this in php3 ? my work currently only has php3 ,
where i am upgrading it for them soon, this is a bummer, i soughta wanna
catch errors and show the line and file in the error too

-Original Message-
From: John W. Holmes [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 29, 2003 4:51 AM
To: 'electroteque'; [EMAIL PROTECTED]
Subject: RE: [PHP] set_error_handler inside a class


 hi guys how is ti possible to do a set_error_handler within a class so
it
 will trigger the callback function and so will be able to return the
line
 and file in the message ?

You'd set it just like you would anywhere else in your code.

If you want the callback function to be a method in your class, then you
pass an array to set_error_handler(). Details are in the manual on the
format of the array. It'll be the same as any other callback function
that you can send a classes method to.

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] set_error_handler inside a class

2003-01-28 Thread 1LT John W. Holmes
 sorry is there a way to do this in php3 ? my work currently only has php3
,
 where i am upgrading it for them soon, this is a bummer, i soughta wanna
 catch errors and show the line and file in the error too

Nope... it's 4.0.1 and higher only. UPGRADE!! :)

---John Holmes...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] set_error_handler() Keeps Triggering Errors

2002-11-10 Thread Ernest E Vogelsinger
At 06:34 10.11.2002, Monty said:
[snip]
When I use set_error_handler('error_function') in my scripts, errors are
constantly being triggered that I've never seen before. If I comment the
handler function out, the errors go away. I have the error reporting set
very loosely: error_reporting (E_ERROR | E_USER_ERROR) - so not sure why it

It's somewhere in the docs - can't remember where just now, I believe
isomewhere in the user comments for error_handler:

your error_handler gets _all_ type of error,warning,notice, regardless of
the actual setting of error_reporting (which only decides if the
error/warning/notice gets sent to the client or not).

keeps triggering an error, because the error I keep getting is:

Undefined variable: target

This is the same error message no matter what script I run. I don't even use
a variable named $target anywhere in any of my scripts, so, this is
baffling. And this seems like an E_NOTICE error message, but, I'm only
asking for E_ERROR and E_USER_ERROR notices.
[snip] 

Might point to a dynamic variable named target:

?php
error_reporting(E_ALL);
$varname = 'target';
if ($$varname) {
;
}
?


gets me
Notice: Undefined variable: target in /www/test/test.php on line 4

Do a grep for target on your source files.


-- 
   O Ernest E. Vogelsinger
   (\)ICQ #13394035
^ http://www.vogelsinger.at/



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] set_error_handler() Keeps Triggering Errors

2002-11-10 Thread Monty
Hi Earnest. I found these user notes in the PHP manual, but, it's confusing
and seems to be a bit contradictory:

-[snip]-

error_reporting() has no effect if you have defined your own error handler
with set_error_handler()

[Editor's Note: This is not quite accurate.

E_ERROR, E_PARSE, E_CORE_ERROR, E_CORE_WARNING, E_COMPILE_ERROR and
E_COMPILE_WARNING error levels will be handled as per the error_reporting
settings. 

All other levels of errors will be passed to the custom error handler
defined by set_error_handler().

-[/snip]-

PHP's error-handling seems to need to re-working. I just can't get this to
work after having tried some other things I found online. All I want is for
PHP to NOT report E_NOTICE errors, but, there seems to be no way to do this,
even if I re-define the E_NOTICE constant vars.

Thanks.


 From: [EMAIL PROTECTED] (Ernest E Vogelsinger)
 Newsgroups: php.general
 Date: Sun, 10 Nov 2002 10:42:05 +0100
 To: Monty [EMAIL PROTECTED]
 Cc: [EMAIL PROTECTED]
 Subject: Re: [PHP] set_error_handler() Keeps Triggering Errors
 
 At 06:34 10.11.2002, Monty said:
 [snip]
 When I use set_error_handler('error_function') in my scripts, errors are
 constantly being triggered that I've never seen before. If I comment the
 handler function out, the errors go away. I have the error reporting set
 very loosely: error_reporting (E_ERROR | E_USER_ERROR) - so not sure why it
 
 It's somewhere in the docs - can't remember where just now, I believe
 isomewhere in the user comments for error_handler:
 
 your error_handler gets _all_ type of error,warning,notice, regardless of
 the actual setting of error_reporting (which only decides if the
 error/warning/notice gets sent to the client or not).
 
 keeps triggering an error, because the error I keep getting is:
 
 Undefined variable: target
 
 This is the same error message no matter what script I run. I don't even use
 a variable named $target anywhere in any of my scripts, so, this is
 baffling. And this seems like an E_NOTICE error message, but, I'm only
 asking for E_ERROR and E_USER_ERROR notices.
 [snip]
 
 Might point to a dynamic variable named target:
 
 ?php
 error_reporting(E_ALL);
 $varname = 'target';
 if ($$varname) {
 ;
 }
 ?
 
 
 gets me
 Notice: Undefined variable: target in /www/test/test.php on line 4
 
 Do a grep for target on your source files.
 
 
 -- 
 O Ernest E. Vogelsinger
 (\)ICQ #13394035
 ^ http://www.vogelsinger.at/
 
 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] set_error_handler() Keeps Triggering Errors

2002-11-10 Thread Michael Sims
On Sun, 10 Nov 2002 10:48:46 -0500, you wrote:

Hi Earnest. I found these user notes in the PHP manual, but, it's confusing
and seems to be a bit contradictory:

It's simple:  A user defined error handler cannot handle parse errors
or compile time errors.  That makes sense to me...if your script
doesn't parse and can't complete the compile phase then how would you
expect your custom function to be able to handle the error?  It hasn't
been compiled yet...

I just can't get this to
work after having tried some other things I found online. All I want is for
PHP to NOT report E_NOTICE errors, but, there seems to be no way to do this,
even if I re-define the E_NOTICE constant vars.

The answer is in the editor's note that you quoted, two paragraphs
after you snipped the quote:

if (!($type  error_reporting())) return;

$type is the error code..i.e. the first parameter passed to your error
handler.  Add that line to the top of your error handling function and
it will behave the way you expect.

PHP's error reporting value is a bitmask...a combination of all of the
error type constants that you want PHP to report.  The line of code
above takes the current error's bit value and does a bitwise AND with
the error reporting level.  If the result is 0, that means that the
current error's bit value is not turned on in the current error
reporting level.  If this is so, then the line above will return from
your error handling function without doing anything...effectively
ignoring the error.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] set_error_handler() not catching some errors

2002-02-09 Thread Michael Sims

At 04:36 PM 2/9/2002 -0800, Charlie Killian wrote:
But others like not including a semicolon returns nothing:
$d = 3

The page is not returned there is no error and the page is stopped being
parsed.

This is by design.  Quoting from http://bugs.php.net/bug.php?id=9386:

quote
[17 Jun 2001 4:56am] [EMAIL PROTECTED]
FATAL errors are not passed through user error handlers due to the fact
the engine may be unstable and this could present security issues,
instead the engine reports the error via its default mechanism as
described in php.ini and then shutsdown as gracefully as possible.

- James
/quote

Sounds like you have your php.ini configured to not display errors, since 
you are not seeing the parse error message in your HTML output...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] set_error_handler() not catching some errors

2002-02-09 Thread Charlie Killian

Thanks Mike. I updated display_errors = On and now I see the errors.

Charlie


 Sounds like you have your php.ini configured to not display errors, since
 you are not seeing the parse error message in your HTML output...




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] set_error_handler scope problems?

2001-05-17 Thread Dean Hall

Eek. Nevermind.

The problem, for anyone who is interested, is that you cannot specify that
any parameters in the error-handler function to be passed by reference.

Dean.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] set_error_handler()

2001-04-17 Thread Dean Hall

""Boget, Chris"" [EMAIL PROTECTED] wrote:
 Can you use the above function to set the error
 handler to a custom class?  If so, how?  I've been
 having no luck no matter what I do...

 Chris

Chris.

I tried doing something like:

set_error_handler("Error::handleError");

myself, and to no avail. It seems that the namespace resolution in PHP is
still very primitive. I know "Error::handleError()" will work in normal
context, but it doesn't seem to work in dynamic evaluations. Perhaps when
PHP gets real namespace support.

Dean.
http://hall.apt7.com



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] set_error_handler()

2001-04-17 Thread Boget, Chris

 ""Boget, Chris"" [EMAIL PROTECTED] wrote:
  Can you use the above function to set the error
  handler to a custom class?  If so, how?  I've been
  having no luck no matter what I do...
 I tried doing something like:
 set_error_handler("Error::handleError");
 myself, and to no avail. It seems that the namespace 
 resolution in PHP is still very primitive. I know 
 "Error::handleError()" will work in normal context, 
 but it doesn't seem to work in dynamic evaluations. 
 Perhaps when PHP gets real namespace support.

Well, in the mean time, I found a way around it that
seems to work ok. :P  What I did is included in the
last message I sent in this thread.

Chris



Re: [PHP] set_error_handler()

2001-04-16 Thread Morgan Curley

If I'm not mistaken set_error_handler() takes a string that is the name of 
a function, I am sure in that function you can instantiate whatever class 
you want.

morgan

At 03:57 PM 4/16/2001, Boget, Chris wrote:
Can you use the above function to set the error
handler to a custom class?  If so, how?  I've been
having no luck no matter what I do...

Chris



RE: [PHP] set_error_handler()

2001-04-16 Thread Boget, Chris

 If I'm not mistaken set_error_handler() takes a string that 
 is the name of a function, I am sure in that function you can 
 instantiate whatever class you want.

I thought about that.  But ideally, what I'm trying to do is
trap the errors with a class method (after instantiating) 
then print out or handle the errors all at once.  
Kind of like this:

pseudocode

$myErrors = new ErrorClass;

$old_error_handler = set_error_handler( "myErrors-handler" );

// all of these will be caught with my class' method
trigger_error( "Error 1", E_USER_WARNING );
trigger_error( "Error 2", E_USER_WARNING );
trigger_error( "Error 3", E_USER_WARNING );

$myErrors-printAllErrors();

/pseudocode

Or something along those lines.  Using the function to instiate the
class and process the error basically makes the class moot.  Why
would you really need the class in the first place?  You would just
have the function do all the work.

Chris



RE: [PHP] set_error_handler()

2001-04-16 Thread Boget, Chris

 If I'm not mistaken set_error_handler() takes a string that 
 is the name of a function, I am sure in that function you 
 can instantiate whatever class you want.

After thinking about it some more, I'm doing this.  Not sure
if this is the best way to go about it, but it allows me to do
what I want:

?

function errorWrapperFunction( ... error_handler_vars ... ) {
  
  global $ErrorClassName;

  $ErrorClassName-errorHandlerMethod( ... error_handler_vars ... );

}

class ErrorHandlerClass {

  // constructor
  function ErrorHandlerClass() {

$GLOBALS["ErrorClassName"] = get_class( $this );

  }
}

$old_error_handler = set_error_handler( "errorWrapperFunction" );

?

That way, I can still use my class to do everything else and handle
the errors when and where I need/want.

Chris