hyperpolyglot icon indicating copy to clipboard operation
hyperpolyglot copied to clipboard

PHP stuff

Open hikari-no-yume opened this issue 9 years ago • 2 comments

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

hikari-no-yume avatar Feb 28 '15 15:02 hikari-no-yume

I've added the items which apply to PHP 5.5.

clarkgrubb avatar Mar 02 '15 03:03 clarkgrubb

Why not 5.6?

hikari-no-yume avatar Mar 02 '15 09:03 hikari-no-yume