Ausdrücke (expressions) in PHP
Ausdrücke werden aus Operatoren, Operanden und Klammern gebildet. Z.B. sind $a+5 oder $a<5 Ausdrücke. Der erste Ausdruck hat einen Zahlenwert, der zweite kann den Wert TRUE oder FALSE haben. Vereinfacht könnte man formulieren: "Ein Ausdruck ist irdendetwas, das einen Wert hat". Es gibt- arithmetische Ausdrücke
- logische Ausdrücke
- Vergleichsausdrücke
- Zeichenketten-Ausdrücke
- Arithmetische Operatoren
- String Operator
- Bit Operatoren
- Logische Operatoren
- Vergleichsoperatoren
- Inkrementoperatoren
Arithmetische Operatoren
example | name | result |
---|---|---|
$a + $b | Addition | Sum of $a and $b. |
$a - $b | Subtraction | Remainder of $b subtracted from $a. |
$a * $b | Multiplication | Product of $a and $b. |
$a / $b | Division | Dividend of $a and $b. |
$a % $b | Modulus | Remainder of $a divided by $b. |
String Operator
example | name | result |
---|---|---|
"Hello " . "world!" | Concatenation | Hello world! |
Bit Operatoren
example | name | result |
---|---|---|
$a & $b | And | Bits that are set in both $a and $b are set. |
$a | $b | Or | Bits that are set in either $a or $b are set. |
~ $a | Not | Bits that are set in $a are not set, and vice versa. |
Logische Operatoren
example | name | result |
---|---|---|
$a and $b | And | True of both $a and $b are true. |
$a or $b | Or | True if either $a or $b is true. |
$a xor $b | Or | True if either $a or $b is true, but not both. |
! $a | Not | True if $a is not true. |
$a && $b | And | True of both $a and $b are true. |
$a || $b | Or | True if either $a or $b is true. |
Vergleichsoperatoren
example | name | result |
---|---|---|
$a == $b | Equal | True if $a is equal to $b. |
$a != $b | Not equal | True if $a is not equal to $b. |
$a < $b | Less than | True if $a is strictly less than $b. |
$a > $b | Greater than | True if $a is strictly greater than $b. |
$a <= $b | Less than or equal to | True if $a is less than or equal to $b. |
$a >= $b | Greater than or equal to | True if $a is greater than or equal to $b. |