PHP 7.0

New Features

Justin King

@getafixx

#20yearsofphp @sydphp #sydphp

30 July 2015

that I like*

20 YEARS OF PHP!??

#20yearsofphp @sydphp #sydphp @getfixx

PHP 7 Features

Combined Comparison Operator
Null Coalesce Operator
Scalar Type Declarations
Return Type Declarations
Anonymous Classes
Unicode Codepoint Escape Syntax
Closure call() Method
Filtered unserialize()

IntlChar Class
Expectations

Group use Declarations
Generator Return Expressions
Generator Delegation
Integer Division with intdiv()
session_start() Options
preg_replace_callback_array() Function
CSPRNG Functions
Support for Array Constants in define()

PHP 7 Changes

Loosening Reserved Word Restrictions
Uniform Variable Syntax
Exceptions in the Engine
Throwable Interface
Integer Semantics
JSON Extension Replaced with JSOND
ZPP Failure on Overflow
Fixes to foreach()'s Behaviour
Changes to list()'s Behaviour
Changes to Division by Zero Semantics

Fixes to Custom Session Handler Return Values
Deprecation of PHP 4-Style Constructors
Removal of date.timezone Warning
Removal of Alternative PHP Tags
Removal of Multiple Default Blocks in Switch Statements
Removal of Dead Server APIs
Removal of Hex Support in Numerical Strings
Removal of Deprecated Functionality
Reclassification and Removal of E_STRICT Notices
Deprecation of Salt Option for password_hash()

Performance

  • 100%+ performance gain on most real-world applications

  • Lower memory usage

PHP 7 performance chart comparisons

 

http://talks.php.net/oz15#/wpbench

https://www.zend.com/en/resources/php7_infographic

Performance

https://www.zend.com/en/resources/php7_infographic

Performance

https://www.zend.com/en/resources/php7_infographic

spaceship operator

<=>

Combined Comparison Operator

shorthand notation for performing three-way comparisons from two operands

// compares strings lexically
var_dump('PHP' <=> 'Node'); // int(1)

// compares numbers by size
var_dump(123 <=> 456); // int(-1)

// compares corresponding array elements with one-another
var_dump(['a', 'b'] <=> ['a', 'b']); // int(0)

Null Coalesce Operator

??

The null coalesce operator (or isset ternary operator) is a shorthand notation for performing isset() checks in the ternary operator. 

// Pre PHP 7 code
$route = isset($_GET['route']) ? $_GET['route'] : 'index';

// PHP 7+ code
$route = $_GET['route'] ?? 'index';

Credits

Rasmus Lerdorf 

@rasmus

http://talks.php.net/oz15

Thomas Punt

https://github.com/tpunt/PHP7-Reference

Zend.com

https://www.zend.com/en/resources/php7_infographic

Thanks

Justin King

 

@getafixx

 

#20yearsofphp

 

@sydphp #sydphp

https://slides.com/getafixx/sydphp-php7-features

#ashes2015 #eng

Made with Slides.com