Hi,
Just use single quotes! It gets too messy when you are trying to escape everything.
The following works just fine.
<?php
$formula ='$my_profit * 0.4';
$my_profit = 1000;
echo $formula.'<br>'; // this returns: $my_profit * 0.4
eval('$formula = '.$formula.';');
echo $formula.'<br>'; // this returns: 400
?>
Using the single quotes means that PHP will not try to evaluate the variables inside the string before you want it to.