I have this simple PHP code:
<?php
$code = "echo 'Hello World'; }";
call_user_func(create_function('', $code));
As you see, my $code
has syntax error. When I run this, I get this result:
Parse error: syntax error, unexpected '}' in file.php(4) : runtime-created function on line 1
Warning: call_user_func() expects parameter 1 to be a valid callback, no array or string given in file.php on line 4
How can I get the Parse error into a variable? For example:
$error = some_func_to_get_error();
echo $error;
// Parse error: syntax error, unexpected '}' in file.php(4) : runtime-created function on line 1