Category Archives: Reference

PHP new syntax reference

PHP introduces new language features with every release. As such, it can be difficult keeping track of them all and remembering which features can be used in which version. So below we list the major syntax changes in each version along with a short example.

PHP 7.4

Typed properties

Type declarations on class variables.

class Foo
    public int $bar;
    private string $qux;

Arrow functions

Shorthand syntax for anonymous functions; includes automatic variable binding (no need for ‘use’).

$foo = 3;
$multiplyFoo = fn($n) => $n * $foo;
Continue reading PHP new syntax reference