title: How to access parse error in runtime-created function in PHP?
body: <p>I have this simple PHP code:</p>
  
  <pre><code>&lt;?php
  
  $code = "echo 'Hello World'; }";
  call_user_func(create_function('', $code));
  </code></pre>
  
  <p>As you see, my <code>$code</code> has syntax error. When I run this, I get this result:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>How can I get the <strong>Parse error</strong> into a variable? For example:</p>
  
  <pre><code>$error = some_func_to_get_error();
  echo $error;
  // Parse error: syntax error, unexpected '}' in file.php(4) : runtime-created function on line 1
  </code></pre>