The standard +,-,*,/,%. No exponents. There is a unary -.
$a = 1 + 2 * 3 / 4 % -5;
Comparison
The standard <, <=, ==, >=, >, and !=. You can use <> as
an alias for !=.
Note that = is assignment and == is equality. Get them right.
What does this code do? Hint: It produces no error.
if ($a = 7) {
echo("Yep");
}
Logical Operators
The standard &&, ||, and !. You can also use "and", "or",
and "not", but that might help code readability.
String Concatenation
The string concatenation operator is ".". Example: $a=$b.$c.
You can also use embedded strings like this. $a="$b $c";Note the
difference between echo("4" . "5"); and echo(4 . 5);
Trenary Operator
C, C++,and Perl all have this too. Weird, yet useful.
The standard &, |, ~, and ^. BTW, "^" means exclusive or, and
"~" mans bitwise negation.. Examples:
$a = $b | 1; // What would this mean? $a = ~$b|1;// What about this? These are NOT a replacement for the logical operators, but you
might get away with that sometimes. I predict the computer Gods will
curse you to Valhalla if you try it though.
The shifts are << and >>. Examples:
$a = $b >> 3 + $b >> 1; // What's this?
Error Suppression
To ignore an error, precede the line with "@". Great way to
avoid divide by zero errors.
@$a = $b / $c; The Shortcuts
You get the standard shortcuts that C++ and Java offer.
Namely, ++, --, +=, -=, and so on.