I have 3 variables and a formula that trusted users need to be able to define via a CMS. This formula will change over time and the value of the variables come from a database.
How can I work out the answer to the calculation? I assume eval is relevant but can't quite get it to work
$width = 10;
$height = 10;
$depth = 10;
$volumetric = '(W*H*D)/6000';
$volumetric = str_replace('W', $width, $volumetric);
$volumetric = str_replace('H', $height, $volumetric);
$volumetric = str_replace('D', $depth, $volumetric);
eval($volumetric);
This gives me:
Parse error: parse error in /path/to/vol.php(13) : eval()'d code on line 1