Discussion:
Does a call to trigger_error ever return?
Peter West
2013-10-26 08:43:59 UTC
Permalink
As it says. I'm a complete php nube, but form what I can see, and from
some tests of interactive php, trigger_error is effectively an exit from
the flow of control. (I'm not sure where it exits to, or how it can be
made to change its mind.)

So I need to confirm whether I have the right end of the stick, and I
need to know, especially, if I ever need to provide for a return from
trigger_error in the flow of code.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Tim Streater
2013-10-26 09:19:00 UTC
Permalink
Post by Peter West
As it says. I'm a complete php nube, but form what I can see, and from
some tests of interactive php, trigger_error is effectively an exit from
the flow of control. (I'm not sure where it exits to, or how it can be
made to change its mind.)
So I need to confirm whether I have the right end of the stick, and I
need to know, especially, if I ever need to provide for a return from
trigger_error in the flow of code.
If you use for example an unitialised variable, such as in:

$i = $j;

where $j had not yet been set to some value, then generally speaking program flow is interrupted, possibly some messages may be put out, and your program exits. If you use trigger_error then I'd guess (without having tried it) that something similar occurs. To alter the behaviour of your program either on a real error or one you trigger, you can use set_error_handler which allows you to tell PHP that you want to use your own error handling function rather than PHP's. For fuller information, have a look at:

<http://www.php.net/manual/en/book.errorfunc.php>
--
Cheers -- Tim
Continue reading on narkive:
Loading...