SlideShare a Scribd company logo
THENEWFEATURESOFPHP7THENEWFEATURESOFPHP7
by -
Senior Software Engineer
, a Rogue Wave Company (USA)
, Milan, 25th Nov. 2016
Enrico Zimuel @ezimuel
Zend Technologies
Codemotion
The new features of PHP 7
PHPPHP
PHP: Hypertext Preprocessor
The most popular server-side language: PHP is used by
82.3% of all the websites (source: )
Used by Facebook, Wikipedia, Yahoo, Etsy, Flickr,
Digg, etc
21 years of usage, since 1995
Full OOP support since PHP 5
w3techs.com
PHPECOSYSTEMPHPECOSYSTEM
CMS: , , , etc
E-commerce: , , , etc
CRM: , , , , etc
Wiki: , , , etc
Framework: , , , etc
Drupal Wordpress Joomla
Magento OpenCart PrestaShop
CiviCRM SugarCRM Vtiger Zurmo
DokuWiki MediaWiki PmWiki
Laravel Symfony Zend Framework
PHP7PHP7
Released: 3 December 2015
Last major was , 13 July 2004 (11 years!)PHP 5
Last release is (10 Nov 2016)7.0.13
PHP6?PHP6?
Unicode support at the core language level
Not released, project is abandoned
PHPDEADLINESPHPDEADLINES
Version Release Supported until
5.3 30 June 2009 14 August 2014
5.4 1 March 2012 3 September 2015
5.5 20 June 2013 21 July 2016
5.6 28 August 2014 31 December 2018
7.0 3 December 2015 3 December 2018
7.1 December 2016? 3 years
PHP7INANUTSHELLPHP7INANUTSHELL
Great performance (thanks to )
Return/Scalar Type Declarations
Cryptographic secure pseudo-random number
generator (CSPRNG)
Anonymous Classes
Combined Comparison (Spaceship) Operator
Null coalescing operator
New Error hierarchy
PHPNG
PERFORMANCEPERFORMANCE
, PHP Next GenerationPHPNG
Project by Dmitry Stogov ( )Zend
New data structure management in the PHP engine
Great performance improvement!
BENCHMARKBENCHMARK
$a = [];
for ($i = 0; $i < 1000000; $i++) {
$a[$i] = ["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
OTHERLANGUAGESOTHERLANGUAGES
PHP 7 is also faster than !Python 3
PHP 7 is also faster than !Python 3
WORDPRESSWORDPRESS
CASESTUDIESCASESTUDIES
Badoo saved one million dollars switching to PHP 7
( )
Tumblr reduced the latency and CPU load by half
moving to PHP 7 ( )
Dailymotion handles twice more traffic with same
infrastructure switching to PHP 7 ( )
source
source
source
RETURNTYPEDECLARATIONSRETURNTYPEDECLARATIONS
function foo(): array {
return [];
}
function bar(): DateTime {
return null; // invalid
}
More information: PHP documentation
SCALARTYPEDECLARATIONSSCALARTYPEDECLARATIONS
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)
More information: PHP documentation
CSPRNGCSPRNG
Cryptographically secure pseudo-random number
generators
// generates a random number between 1 and 100
$num = random_int(1,100);
// generates a random string of 1 Kb
$bytes = random_bytes(1024);
More information: PHP documentation
ANONYMOUSCLASSESANONYMOUSCLASSES
/* 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
More information: PHP documentation
SPACESHIPOPERATORSPACESHIPOPERATOR
A <=> B
0 if A == B, 1 if A > B, -1 if A < B
echo 1 <=> 1; // 0
echo 1 <=> 2; // -1
echo 2 <=> 1; // 1
echo "a" <=> "a"; // 0
echo "a" <=> "b"; // -1
echo "b" <=> "a"; // 1
NULLCOALESCINGNULLCOALESCING
?? operator
// Fetches the value of $_GET['user'] and returns 'nobody'
// if it does not exist.
$username = $_GET['user'] ?? 'nobody';
// This is equivalent to:
$username = isset($_GET['user']) ? $_GET['user'] : 'nobody';
// Coalescing can be chained
$username = $_GET['user'] ?? $_POST['user'] ?? 'nobody';
NEWERRORHIERARCHYNEWERRORHIERARCHY
Throwable: Error, Exception
function call_method($obj) {
$obj->method();
}
try {
call_method(null); // oops!
} catch (Error $e) {
printf ("Error: %sn", $e->getMessage());
} catch (Exception $e) {
printf ("Exception: %sn", $e->getMessage());
}
More information: PHP documentation
MUCHMORE...MUCHMORE...
Consistent 64-bit support
Fix list() behavior inconsistency
Filtered unserialize()
Group use declarations
Closure::call()
Expectations
...
Check the at php.netPHP 7 new features
PHP7.1PHP7.1
Nullable types
Void return types
Deprecation of Mcrypt ext
Support of in OpenSSL
Support class constant visibility
Iterable pseudo-type
...
Authenticated Encryption
Check the at php.netPHP 7.1 new features
THANKS!THANKS!
Contact me: enrico.zimuel [at] roguewave.com
Blog and web site: www.zimuel.it
Follow me: @ezimuel
This work is licensed under a
.
I used to make this presentation.
Creative Commons Attribution-ShareAlike 3.0 Unported License
reveal.js

More Related Content

PPTX
PHP7 Presentation
PPTX
A new way to develop with WordPress!
PDF
PHP7 - Scalar Type Hints & Return Types
PDF
Key features PHP 5.3 - 5.6
PPTX
Introducing PHP Latest Updates
ODP
PHP5.5 is Here
PDF
Melhorando sua API com DSLs
PDF
IPC2010SE Doctrine2 Enterprise Persistence Layer for PHP
PHP7 Presentation
A new way to develop with WordPress!
PHP7 - Scalar Type Hints & Return Types
Key features PHP 5.3 - 5.6
Introducing PHP Latest Updates
PHP5.5 is Here
Melhorando sua API com DSLs
IPC2010SE Doctrine2 Enterprise Persistence Layer for PHP

What's hot (20)

PDF
What's new in PHP 5.5
PPTX
Webrtc mojo
ODP
ekb.py - Python VS ...
ZIP
Web Apps in Perl - HTTP 101
KEY
Zend Framework Study@Tokyo #2
KEY
Yapcasia2011 - Hello Embed Perl
PDF
Perl web frameworks
KEY
GettingStartedWithPHP
ODP
Php in 2013 (Web-5 2013 conference)
PDF
Codeigniter4の比較と検証
PDF
Quick tour of PHP from inside
KEY
関西アンカンファレンス PHP ではじめるテストコード
PDF
Controlling Arduino With PHP
PDF
PHP7 is coming
PDF
関西PHP勉強会 php5.4つまみぐい
PPTX
Php 7 hhvm and co
KEY
Kansai.pm 10周年記念 Plack/PSGI 入門
PDF
Diving into HHVM Extensions (PHPNW Conference 2015)
PPTX
Zephir - A Wind of Change for writing PHP extensions
PDF
Pl python python w postgre-sql
What's new in PHP 5.5
Webrtc mojo
ekb.py - Python VS ...
Web Apps in Perl - HTTP 101
Zend Framework Study@Tokyo #2
Yapcasia2011 - Hello Embed Perl
Perl web frameworks
GettingStartedWithPHP
Php in 2013 (Web-5 2013 conference)
Codeigniter4の比較と検証
Quick tour of PHP from inside
関西アンカンファレンス PHP ではじめるテストコード
Controlling Arduino With PHP
PHP7 is coming
関西PHP勉強会 php5.4つまみぐい
Php 7 hhvm and co
Kansai.pm 10周年記念 Plack/PSGI 入門
Diving into HHVM Extensions (PHPNW Conference 2015)
Zephir - A Wind of Change for writing PHP extensions
Pl python python w postgre-sql
Ad

Viewers also liked (15)

PDF
2015 09 23_prezentatsia
DOCX
แบบเสนอโครงร่างโครงงานคอมพิวเตอร์
PPTX
Keeping up with PHP
PDF
Lean Six SIgma Green Belt
PDF
Lecture 1
PPTX
Hub and Spoke Presentation
PPTX
Турбюро «Компас»
PPTX
Aims Tutorials Pvt. Ltd.
PDF
PPTX
Getting started with PHP on IBM i
PDF
Running open source PHP applications on you IBM i
PPTX
PHP Installed on IBM i - the Nickel Tour
PPT
Ethics In Education Shankara Narayanan
PPTX
Reaction Injection Molding Tooling
PDF
Was_there_room_for_monetary_discretion_under_the_gold_standard
2015 09 23_prezentatsia
แบบเสนอโครงร่างโครงงานคอมพิวเตอร์
Keeping up with PHP
Lean Six SIgma Green Belt
Lecture 1
Hub and Spoke Presentation
Турбюро «Компас»
Aims Tutorials Pvt. Ltd.
Getting started with PHP on IBM i
Running open source PHP applications on you IBM i
PHP Installed on IBM i - the Nickel Tour
Ethics In Education Shankara Narayanan
Reaction Injection Molding Tooling
Was_there_room_for_monetary_discretion_under_the_gold_standard
Ad

Similar to The new features of PHP 7 (20)

PPTX
Php7 HHVM and co
ODP
PHP: The easiest language to learn.
PDF
What To Expect From PHP7
PPTX
Php7 hhvm and co
PPT
Php mysql training-in-mumbai
PPT
PDF
Introduction to PHP
PPTX
Unit 5-PHP Declaring variables, data types, array, string, operators, Expres...
PPT
Php mysql training-in-mumbai
PDF
CodePolitan Webinar: The Rise of PHP
ODP
The why and how of moving to php 5.4
PPT
Php Tutorial
PPT
Php with my sql
PPTX
PHP Hypertext Preprocessor
PPTX
PHP.pptx is the Best Explanation of ppts
PDF
Introduction to PHP - Basics of PHP
PPT
3. build your own php extension ai ti aptech
PPT
07 build your-own_php_extension
Php7 HHVM and co
PHP: The easiest language to learn.
What To Expect From PHP7
Php7 hhvm and co
Php mysql training-in-mumbai
Introduction to PHP
Unit 5-PHP Declaring variables, data types, array, string, operators, Expres...
Php mysql training-in-mumbai
CodePolitan Webinar: The Rise of PHP
The why and how of moving to php 5.4
Php Tutorial
Php with my sql
PHP Hypertext Preprocessor
PHP.pptx is the Best Explanation of ppts
Introduction to PHP - Basics of PHP
3. build your own php extension ai ti aptech
07 build your-own_php_extension

More from Zend by Rogue Wave Software (20)

PDF
Develop microservices in php
PPTX
Speed and security for your PHP application
PPTX
Building and managing applications fast for IBM i
PDF
Building web APIs in PHP with Zend Expressive
PPTX
To PHP 7 and beyond
PDF
Speed up web APIs with Expressive and Swoole (PHP Day 2018)
PDF
The Sodium crypto library of PHP 7.2 (PHP Day 2018)
PDF
Develop web APIs in PHP using middleware with Expressive (Code Europe)
PDF
Middleware web APIs in PHP 7.x
PPTX
Ongoing management of your PHP 7 application
PDF
Developing web APIs using middleware in PHP 7
PDF
The Docker development template for PHP
PDF
The most exciting features of PHP 7.1
PPTX
Unit testing for project managers
PPTX
Deploying PHP apps on the cloud
PPTX
Data is dead. Long live data!
PPTX
Optimizing performance
PPTX
Resolving problems & high availability
PPTX
Developing apps faster
PPTX
Fundamentals of performance tuning PHP on IBM i
Develop microservices in php
Speed and security for your PHP application
Building and managing applications fast for IBM i
Building web APIs in PHP with Zend Expressive
To PHP 7 and beyond
Speed up web APIs with Expressive and Swoole (PHP Day 2018)
The Sodium crypto library of PHP 7.2 (PHP Day 2018)
Develop web APIs in PHP using middleware with Expressive (Code Europe)
Middleware web APIs in PHP 7.x
Ongoing management of your PHP 7 application
Developing web APIs using middleware in PHP 7
The Docker development template for PHP
The most exciting features of PHP 7.1
Unit testing for project managers
Deploying PHP apps on the cloud
Data is dead. Long live data!
Optimizing performance
Resolving problems & high availability
Developing apps faster
Fundamentals of performance tuning PHP on IBM i

Recently uploaded (20)

PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PPTX
ai tools demonstartion for schools and inter college
PDF
System and Network Administration Chapter 2
PPTX
Odoo POS Development Services by CandidRoot Solutions
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PDF
How Creative Agencies Leverage Project Management Software.pdf
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
System and Network Administraation Chapter 3
PPTX
Operating system designcfffgfgggggggvggggggggg
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
Digital Strategies for Manufacturing Companies
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Which alternative to Crystal Reports is best for small or large businesses.pdf
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
ai tools demonstartion for schools and inter college
System and Network Administration Chapter 2
Odoo POS Development Services by CandidRoot Solutions
Upgrade and Innovation Strategies for SAP ERP Customers
How Creative Agencies Leverage Project Management Software.pdf
Softaken Excel to vCard Converter Software.pdf
System and Network Administraation Chapter 3
Operating system designcfffgfgggggggvggggggggg
VVF-Customer-Presentation2025-Ver1.9.pptx
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
How to Migrate SBCGlobal Email to Yahoo Easily
Wondershare Filmora 15 Crack With Activation Key [2025
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Digital Strategies for Manufacturing Companies
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx

The new features of PHP 7