Re: set_error_handler always returns false
| From: | Lars Torben Wilson | Date: | Mon, 23 Jun 2003 22:21:34 +0000 |
| Subject: | Re: set_error_handler always returns false | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-152546@lists.php.net to get a copy of this message | ||
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 <torben@php.net> +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 ====-----