by Enrico Zimuel - Twitter: @ezimuel
Senior Sofware Engineer, Zend Technologies Ltd
PUG Torino, 29th April 2015
Professional Developer since 1996. Senior Software Engineer at Zend Technologies, since 2008. Research in computer science at the Informatics Institute of Amsterdam University. Open source contributor and co-author of Apigility and Zend Framework. Co-author of the Italian books PHP Best Practices and Javascript Best Practices. Co-founder of PUG Torino (Italy).
Release scheduled for October 2015
Last major was PHP 5, 13 July 2004 (11 years ago!)
Last stable release is 5.6.8 (16 April 2015)
Unicode support at the core language level
Not released, project is abandoned
Version | Release | Supported until |
5.3 | 30 June 2009 | 14 August 2014 |
5.4 | 1 March 2012 | September 2015 |
5.5 | 20 June 2013 | June 2016 |
5.6 | 28 August 2014 | August 2017 |
7 | October 2015 | October 2018 |
PHPNG, PHP Next Generation
Project by Dmitry Stogov (Zend)
New data structure management in the PHP engine
Great performance improvement!
$a = array();
for ($i = 0; $i < 1000000; $i++) {
$a[$i] = array("hello");
}
echo memory_get_usage(true);
PHP 5.6 | PHP 7 | |
Memory Usage | 428 MB | 33 MB |
Execution time | 0.49 sec | 0.06 sec |
* values are req/sec
function foo(): array {
return [];
}
function bar(): DateTime {
return null; // invalid
}
For more information read PHP RFC
declare(strict_types=1);
function sendHttpStatus(int $statusCode, string $message) {
header('HTTP/1.0 ' .$statusCode. ' ' .$message);
}
sendHttpStatus(404, "File Not Found"); // ok
sendHttpStatus("403", "OK"); // fatal error
function add(float $a, float $b): float {
return $a + $b;
}
add(1, 2); // float(3)
For more information read PHP RFC
/* return an anonymous class */
return new class($controller) implements Page {
public function __construct($controller) {
/* ... */
}
/* ... */
};
class Foo {}
$child = new class extends Foo {};
var_dump($child instanceof Foo); // true
For more information read PHP RFC
Spaceship operator: (exprA) <=> (exprB)
0 if exprA == exprB, 1 if exprA > exprB, -1 if exprA < exprB
echo 1 <=> 1; // 0
echo 1 <=> 2; // -1
echo 2 <=> 1; // 1
echo "a" <=> "a"; // 0
echo "a" <=> "b"; // -1
echo "b" <=> "a"; // 1
For more information read PHP RFC
EngineException to manage exception from PHP engine
function call_method($obj) {
$obj->method();
}
try {
call_method(null); // oops!
} catch (EngineException $e) {
echo "Exception: {$e->getMessage()}\n";
}
For more information read PHP RFC
This RFC proposes setting a standard that internal classes should either return a valid instance of the class or throw an exception
$mf = new MessageFormatter('en_US', '{incorrect}');
if ($mf === null) {
echo "Surprise!";
}
For more information read PHP RFC
Check the RFC Wiki of PHP for the complete list
More information Wiki RFC PHP
Contact me: enrico [at] zend.com
Follow me: @ezimuel
This work is licensed under a
Creative Commons Attribution-ShareAlike 3.0 Unported License.
I used reveal.js to make this presentation.