Handling exit in eval
| From: | Thomas Björk | Date: | Mon, 14 Mar 2011 10:51:05 +0000 |
| Subject: | Handling exit in eval | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-311826@lists.php.net to get a copy of this message | ||
Is there any way to emulate an exit in eval without exiting the calling
script.
<?php
$s = 'echo "Shows"; exit; echo "Doesn\'t show"; ';
eval($s);
echo "Never comes here";
?>
I would like to do something like this:
<?php
$s = 'echo "Shows"; exit; echo "Doesn\'t show"; ';
function MakeItStop() {
// Do something to make the eval stop
// without halting the script
}
$s = str_replace('exit;', 'MakeItStop();', $s);
eval($s);
echo "Never comes here";
?>
A simple return would fix it IF the return isn't located within a
function.
Any good suggestions?
Thanks in advanced
Thomas Björk