K-Meleon
Use this page to experiment with the wiki. (Just don't delete this text; otherwise people won't know the purpose of the page.)
The following operators are available:
Operator | Meaning | Sample Statement | Result (int, string, bool) | |
= | assignment | $x = 7; | $x = 7 | |
. | string concatenation | $x = 7 . 3; | $x = 73 | |
+ | integer addition | $x = 7 + 3; | $x = 10 | |
- | integer subtraction | $x = 7 - 3; | $x = 4 | |
* | integer multiplication | $x = 7 * 3; | $x = 21 | |
/ | integer division | $x = 7 / 3; | $x = 2 | |
% | integer remainder | $x = 7 % 3; | $x = 1 | |
== | equality | $x = 7; $x == 3; | false | |
!= | unequality | $x = 7; $x != 3; | true | |
<, <=, >, >= | string comparison | 10 > 2 | false | |
<, <=, >, >= | integer comparison | 10+0 > 2+0 | true | |
and | comparison join for if(), and while() |
$x=3; $y=2; $x>=$y and $y<7 |
true | |
or | comparison join for if(), and while() |
$x=3; $y=2; $x>=$y or $y>7 |
true | |
? : | conditional expression | $x==1 ? true : false; | if $x equals 1 true, otherwise false |
Parentheses can be used to alter the evaluation order. By default, addition and subtraction have higher precedence than multiplication, division and remainder operations.
When needed, a variable is automatically converted from a string to an integer, or vice versa.
$x = 1 + "2"; $x = 3 $y = "The value of x is " . x; $y = "The value of x is 3"
When comparing variables the type of comparison, string or integer, is based on the type of variable to the left of the expression.