I use eval('1+1')
without any issue in JavaScript but for some reason I can't get this to work in PHP. This is an internal (non-public) webpage so security is not an issue. No matter how I code it I am seeing an 500 Internal Server Error.
I'm trying to do something like this in a PHP file:
$expression='1+1';
echo "eval($expression)";
Is the eval()
function in PHP not the same as the JavaScript equivalent or is it perhaps not as straightforward to implement?