PHP now supports Namespaces

 * User.php
namespace MySpace;

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

 * Application.php
namespace Project;

require 'User.php';

use MySpace\User;

$user = new User();


New jump labels (goto)

// This scrips will only output "Bar"

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


Support for Closures (YAY!)


// 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


Constants can now be declared outside a class



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

// 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


Dynamic access to Static methods

class C {
   public static $foo = 123;

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

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

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.