I’ve got a simple script with a lot of formulas like so:
$formula = 12 *( $C + ($D * $A) + $H ) + $B * ((($F+$J)*$M/$L)+(($G+$K)*$N/$L)+$E);
Is there any easy way to output the values to debug the equation? Like:
12 * ( 15 (44 * 11) + 33) + 3 * [...]
Or I have to to do it the usual way:
echo "12" . '* ('. $C .' + ' [...]
I’ve got lot of these formulas, so I’m looking for some shortcut to debug them.
You should be able to surround your formula with double quotes like so:
That will allow you to echo $formula and all of the variables should be converted to their actual values.
As far as a way to do that without copy/paste or inserting the quotes, no. PHP is going to evaluate all the stuff on the right side of the = so that $formula ends up (without the quotes) with just the final result. If you want the result and the “debug” output you could do this:
Then you’ll get both the answer and the debug output.