<?php
/*
A Trait is intended to reduce some limitations of single inheritance by enabling a developer to reuse sets of methods freely in several independent classes living in different class hierarchies.
*/
trait SayWorld {
function sayHello() {
echo 'World!';
}
}
class MyHelloWorld {
use SayWorld;
}
$o = new MyHelloWorld();
$o->sayHello();
<?php
$a = [1, 2, 3, 4];
// or...
$a = ['one' => 1, 'two' => 2, 'three' => 3, 'four' => 4];
// Also, function array dereferencing has been added
foo()[0];
<?php
// Class member access on instantiation has been added
(new Foo)->bar();
// Binary number format has been added.
$number = 0b001001101;
/*
<?= is now always available
*/
For a full list of changes go here.