Richard Quadling wrote:

> 2011/3/14 Richard Quadling <>:
> And where is my UNDO button.
> Essentially, having exit in the eval code is no different to having it
> in non-eval code. eval isn't a separate entity which can be
> terminated.
> So, code the eval code differently.
> If you can provide some examples, maybe we can come up with a better solution.

I'm developing a kind of sandbox where you will be able to run a script
without affecting your current context. The script is loaded and parsed
which gives me the opportunity to allow or deny functions and classes
used in the script.
The only problem I have so far is the exit function which, it if is
allowed, terminates the calling script as well as the eval'ed script.

By using a return the problem is solved as long as the user doesn't
write a function containing an exit.

Here is a simple script thet the user might write (probably as useful as
a "Hello, world!".

function DoSomethingOrExit($test) {
  if($test == 1) {

echo "Hello";
echo ", world!";
echo "Bye";

By replacing exit with return this code will echo "Hello, world!" before
returning without echoing "Bye".

Another perfect solution would be if there was a way to trigger an error
within the eval'ed script that "crashes" it and returns to the calling
script. But then it just comes back to the entity-problem as you pointed


PHP General Mailing List (
To unsubscribe, visit:

Reply via email to