Reputation: 5303
$fooinstance = new foo();
/*do something*/
exit('bar');
class foo{
__destruct(){
//get the exit message ("bar") to do something with it
}
}
Hello,
I would like to get the exit message to do something with it (for example insert the exit status in a database). Is there a way to do that ?
Thanks
Upvotes: 2
Views: 197
Reputation: 97815
The text exit
sends isn't special; it's just text that's output before the script dies.
You could get the text with output buffering, though I'm not sure it'll be useful:
<?php
$fooinstance = new foo();
ob_start();
exit('bar');
class foo{
function __destruct(){
$c = ob_get_contents(); //$c is "bar"
}
}
It would probably be best to wrap the exit instruction in a function that did the appropriate logging.
Upvotes: 1
Reputation: 29975
This is an incorrect way to do things. Why do you need this particular solution?
Upvotes: 0