php-features-cheatsheet

This cheatsheet outlines when some various handy features were introduced in different versions of PHP.

View on GitHub

PHP CheatSheet

This cheatsheet outlines when some various handy features were introduced in different versions of PHP.

Obviously not intended to be a comprehensive list.

PHP 8.1

enum Color {
  case Red;
  case Green;
  case Blue;
}
$a1 = ["a" => 1];
$a2 = ["b" => 2];

$newArr = [...$a1, ...$a2];

// ["a" => 1, "b" => 2]
function foo(int $a, int $b) { }

$foo = foo(...);
$foo(1, 2);

PHP 8.0

class Thing {
  public function __construct(
  	public string $name = ''
  ) {}
}

$thing = new Thing('Mark');

echo $this->name;
echo match (8.0) {
  '8.0' => "Oh no!",
  8.0 => "This is what I expected",
};

PHP 7.4

PHP 7.3

PHP 7.2

PHP 7.1

PHP 7.0

PHP 5.6