CHAPTER 7 – TYPES OF ERRORS – Eval

All syntax or parse errors are caught during compilation, except errors in code executed with eval(). In the case of eval, the code is compiled during the execution of the script. Here, we modify the previous example with eval: <?php print "Hello!n"; eval("<gobbledigook/>"); ?> This time, the output is different: Hello! Parse error: parse error in /home/ssb/test.php(4) : eval()'d code on line 1 As you can see, this time the error was displayed during execution. This is because code executed with eval() is not compiled until the eval() itself is executed.

Post Comment
Login to post comments