I have +
sign as string and I would like to use it as operator for 2 numbers.
Example:
$n1 = 1;
$n2 = 2;
$plus = '+';
echo $n1 . $plus . $n2;
The previous example would print 1 + 2
, I want to print 3
instead.
I tried to search for a function that could convert the plus string or encode/decode it, But couldn't find a solution.
Also I tried:
echo $n1 + $plus + $n2;
But got this error: WARNING A non-numeric value encountered
Is that possible?