PHP now supports Namespaces

<?php
/*
 * User.php
 */
namespace MySpace;

class User {
  function say() {
    echo 'Hello World';
  } 
}

/*
 * Application.php
 */
namespace Project;

require 'User.php';

use MySpace\User;

$user = new User();
$user->say();

More

New jump labels (goto)

<?php
// This scrips will only output "Bar"

goto a;
echo 'Foo';
 
a:
echo 'Bar';

More

Support for Closures (YAY!)

<?php

// Simplest use: using a Closure as a "parameter" (second)
echo preg_replace_callback('~-([a-z])~', function ($match) {
    return strtoupper($match[1]);
}, 'hello-world');

// outputs helloWorld

More

Constants can now be declared outside a class

<?php
const CONSTANT = 'THE SECRET';

More

Late Static Bindings

This new feature is pretty big to just drop a code sample here, but make sure you check it out here.

Ternary operator has now a new form

<?php
// Normally a Ternary looks like:
$return = (expr1) ? (expr2) : (expr3) 

// Using the new shorthand for is:
$return = (expr1) ?: (expr3)

// Returns expr1 if expr1 evaluates to TRUE, or expr3 otherwise

More

Dynamic access to Static methods

<?php
class C {
   public static $foo = 123;
}

$a = "C";
echo $a::$foo;

Exceptions can be nested. (Why?, I don't know)

<?php
class MyCustomException extends Exception {}

try {
    throw new MyCustomException("Exceptional", 112);
} catch (Exception $e) {
    /* Note the use of the third parameter to pass $e
     * into the RuntimeException. */
    throw new RuntimeException("Rethrowing", 911, $e);
}

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.