Hello,
$expression="1*2";
var_dump(intval($expression));
gives int 1
why ?
Thanks for helping
Hello,
$expression="1*2";
var_dump(intval($expression));
gives int 1
why ?
Thanks for helping
There is using common type cast rules. In string "1*2" second char is not numeric. Takes only left side. https://www.php.net/manual/en/language.types.integer.php#111523
If you are wanting the expression to be evaluated as an expression, use the eval() function.
But this is not recommended unless you filter $expression for dangerous characters.