hyperpolyglot
hyperpolyglot copied to clipboard
PHP stuff
There's a few problems with the PHP one.
Old stuff not included:
-
Script encoding can be set with
declare(encoding='utf-8');
but this is almost meaningless except in obscure cases -
PHP also has
**
instead of pow() for exponentiation -
Strings can be immediately indexed since 5.6
-
For "replicate" under arrays, use
array_fill()
-
For constant definition there is also
const PI = 3.141592;
syntax, which is nicer -
For PHP extra argument behaviour: they're ignored.
-
For variadic functions, there's also the
...
syntax now:function foo($bar, ...$args) { // $args is an array, do something }
-
For the unsplat, ditto:
some_func(...$args);
Exceptions can be re-raised by throwing the caught exception.
New stuff that should be included (at least when PHP 7 is out):
-
intdiv($num, $div)
for proper integer division -
<=>
for three-value comparison -
\u{xxxx}
(variable number of x, supports non-BMP codepoints) Unicode codepoint escape sequence
I've added the items which apply to PHP 5.5.
Why not 5.6?