I would like to know if it is possible to obtain this result:
Subtraction of 5-1 equals 4
I know if I do this I can get it:
$numero = 5;
$numero2 = 1;
$resultado = $numero - $numero2;
echo "La resta de 5-1 es igual a $resultado";
But I want to get that result by doing something like this (I know it's wrong but it's so you understand me)
$numero =5;
echo "La resta de 5-1 es igual a $numero-1";
I would like to know if it is possible to do something like that.
Also know if it is possible to perform a subtraction of numbers in the string in a similar way as I expressed it before, for example:
echo "La resta de 5-1 es igual a 5-1(y que me de 4)";
It is a curiosity that I had.
Thanks in advance
In PHP you cannot perform operations on variables inside strings, for example:
PHP only interprets the variable, without performing any operations.
Things that do work: Concatenate or use replacement functions like
sprintf()