PHP eval() fatal error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Here's the thing: I'm trying to do some dynamic code compilation within PHP using eval(). The code I'm trying to compile raises an E_ERROR (Fatal).

Here's a simple example:

<?php
$code = '  $returnValue = 12*A+;  '; // Clearly incorrect code :-)
$returnValue = 0;

eval($code);
?>

Now, I'd like to catch the error made by eval:

// ...
try {
  eval($code);
} catch (Exception $ex) {
  var_dump($ex);
}
// ...

Problem persists: a fatal error occurs.
Using set_error_handler() and set_exception_handler() is not working either...

Is there any way to gracefully catch this error?

Regards,
Maarten

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux