eval(
, the matching closing
brace is searched and the string inside the enclosing braces is interpreted
as an arithmetic expression. The value of the expression is transformed to
a string and substituted for eval(expression)
.
echo (2*3) # this outputs "(2*3)" echo eval(2*3) # this outputs "6"The arithmetic expression may contain the arithmetic operators
+,-,*,/,**,%
.
In addition to that, the boolean operators ==,!=,<,>,<=,>=
are handled.
The result of applying a boolean operator is an integer 0 or 1.
Zero stands for false, and 1 for true.
The functions cos(), sin(), atan()
are recognised and evaluated.
In every context, where a number is required as a parameter, an arithmetic
expression can be used. In these contexts, enclosing the expression in
eval()
is not required.