Introducing Traits

<?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();

More info on Traits

New Array syntax (YAY!)

<?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];

Other syntax features

<?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.

Hire me!

I'm currently open for new projects or join pretty much any project i may fit in, let me know!

Read about what I do, or contact me for details.

Categories