handling php eval syntax error for mathematic equations
<p>suppose I do this in php:</p>

<pre><code>
eval("\$answer=1--1;");
</code></pre>

<p>The expression 1--1 will lead to a syntax error in eval, my question is how do I detect the error and handle it gracefully? ie: catch error in eval and then print out a helpful message. Right now, it just spits out "Parse error: syntax error, unexpected T_DEC". Unfortunately, the php manual states that it is not possible to catch parse errors with the set_error_handler() function.</p>

<p>This is for a simple school assignment and they have suggested using "eval()".
As the assignment is trivial, perhaps there is no need to worry about these rare cases.</p>
