Say I had this code below:
$operator = "+";
$num1 = 10;
$num2 = 32;
echo "the sum of " . $num1 . " and " . $num2 . " is " . ($num1.$operator.$num2);
As you can see, I'm trying to use a variable to define the operator by concatenating it. However, when running this code, the operator is displayed as plain text instead of being used to answer the question.
Obviously, I get an output like this: "the sum of 10 and 32 is 10+32"
Surely I'm doing something wrong?