Replies: 2 comments
-
The idea is that I'll provide a description and one or more code samples per operator. Ideally we'd also link to the official PHP documentation. @willemvb what seems the most easiest to me is that you come up with a design, and I fill it in with real data, so that you won't have to be bothered with copy pasting, and that I can directly write it in the proper context. What do you think? |
Beta Was this translation helpful? Give feedback.
0 replies
-
@brendt sounds good! Hopefully I can squeeze this in week 49 or 50… sooner will be difficult. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Arithmetic
+$a
: Convert$a
to int or float-$a
: Convert$a
to int or float and invert the sign$a + $b
: Add$a
and$b
$a - $b
: Subtract$b
from$a
$a * $b
: Multiply$a
and$b
$a / $b
: Divide$a
by$b
$a % $b
: Remainder of$a
divided by$b
$a ** $b
: Raising$a
the the$b
th power$a++
: Return$a
, then increment by one++$a
: Increment by one, then return$a
$a--
: Return$a
, then decrement by one--$a
: Decrement by one, then return$a
$a += $b
: Shorthand for$a = $a + $b
$a -= $b
: Shorthand for$a = $a - $b
$a *= $b
: Shorthand for$a = $a * $b
$a /= $b
: Shorthand for$a = $a / $b
$a %= $b
: Shorthand for$a = $a % $b
Comparison
$a == $b
: Equality with type juggling$a != $b
: No equality with type juggling$a <> $b
: No equality with type juggling$a === $b
: Equality without type juggling$a !== $b
: No equality without type juggling$a < $b
:$a
is less then$b
$a <= $b
:$a
is less then or equal to$b
$a > $b
:$a
is greater then$b
$a >= $b
:$a
is greater then or equal to$b
$a && $b
:$a
and$b
$a and $b
: Alias for&&
$a || $b
:$a
or$b
$a or $b
: Alias for||
$a xor $b
:$a
or$b
, but not both!$a
: Not$a
$a <=> $b
: An int less than, equal to, or greater than zero when $a is less than, equal to, or greater than $b, respectively.$a ? $b : $c
: Ternary operatorNull coalescing
$a ?? $b
: Null coalescing$a ??= $b
: Shorthand for$a = $a ?? $b
Bitwise
$a & $b
: Binary and$a | $b
: Binary or$a ^ $b
: Binary xor~$a
: Binary not$a << $b
: Bitshift left (each step means "multiply by two")$a >> $b
: Bitshift right (each step means "divide by two")$a &= $b
: Shorthand for$a = $a & $b
$a |= $b
: Shorthand for$a = $a | $b
$a ^= $b
: Shorthand for$a = $a ^ $b
$a <<= $b
: Shorthand for$a = $a << $b
$a >>= $b
: Shorthand for$a = $a >> $b
Strings
$a . $b
: Concat$a
and$b
"{$a} {$b}"
: Interpolate$a
and$b
in the same string$a .= $b
: Shorthand for$a = $a . $b
Generators
yield
: Yield a value from a generatoryield from
Beta Was this translation helpful? Give feedback.
All reactions