SlideShare a Scribd company logo
Pavel Nikolov
PHP7: Hello World!
Who The Fuck
Is This Guy?
Pavel Nikolov
Pavel Nikolov
@pavkatar

CEO at ApiHawk Technologies,
Geek, API Evangelist. iLover,
Developer, Coffee drinker and
just an irregular person
Sofia, Bulgaria
Hello World!
Version Release Lifetime
Personal Homepage Tools (PHP tools) v.1 June 8, 1995 ~ 2 years
PHPFI (Form Interpreter) v2 November 1997 ~ 1 year
PHP3 June 1998 ~ 2 years
PHP4 May 2000 ~ 4 years
PHP5 July 2004 ~ 11 years
PHP5.3 (PHP 6 - Unicode) June 2009
PHP7 Fall 2015
2015 - 20 Years of PHP
PHP7 CHANGES “UNDER THE HOOD”
PHP Version 5.3 5.4 5.5 5.6 7
Interations per
second
282544 278205 304330 301689 583975
288611 268948 307818 308273 603583
288517 279900 296669 301989 606468
282384 282060 299921 308735 596079
288162 280692 298747 308003 610696
286300 278374 307043 303139 594547
291027 278703 305950 311487 602184
292292 282226 296287 312770 610380
Average 287480 278639 302096 307011 600989
Percentage faster than previous version
N/A -3.08% 8.42% 1.63% 95.76%
Executor: Faster
Executor: Less Memory
32 bit 64 bit
PHP 5.6 7.37 MiB 13.97 MiB
PHP 7.0 3.00 MiB 4.00 MiB
$startMemory = memory_get_usage();
$array = range(1, 100000);
echo memory_get_usage() - $startMemory, " bytesn";
PHP7 CHANGES “UNDER THE HOOD”
• Executor: Faster
• Executor: Less memory
• Compiler: Generates better bytecode
PHP7 CHANGES “UNDER THE HOOD”
• Executor: Faster
• Executor: Less memory
• Compiler: Generates better bytecode
• Parser: Now based on AST (abstract syntax tree)
PHP7 CHANGES “UNDER THE HOOD”
• Executor: Faster
• Executor: Less memory
• Compiler: Generates better bytecode
• Parser: Now based on AST (abstract syntax tree)
• Lexer: Now contex-sensitive with support for semi-reserved words
class Collection {
public function forEach(callable $callback) { /* */ }
public function list() { /* */ }
}
PHP7 CHANGES “UNDER THE HOOD”
• Executor: Faster
• Executor: Less memory
• Compiler: Generates better bytecode
• Parser: Now based on AST (abstract syntax tree)
• Lexer: Now contex-sensitive with support for semi-reserved words
PHP5.6:
PHP Parse error: Syntax error, unexpected T_FOREACH, expecting T_STRING on line 2
PHP Parse error: Syntax error, unexpected T_LIST, expecting T_STRING on line 3
callable class trait extends implements static abstract final public
protected private const enddeclare endfor endforeach endif endwhile
and global goto instanceof insteadof interface namespace new or xor
try use var exit list clone include include_once throw array print echo
require require_once return else elseif default break continue switch
yield function if endswitch finally for foreach declare case do while as
catch die self parent
This is a list of currently globally reserved words that will become semi-reserved
in case proposed change gets approved:
PHP7 CHANGES “UNDER THE HOOD”
Limitation!
It's still forbidden to define a class constant named as class because of the class name resolution ::class:
In practice, it means that we would drop from 64 to only 1 reserved word that affects only class constant names.
class Foo {
const class = 'Foo'; // Fatal error
}
 
// Fatal error: Cannot redefine class constant Foo::CLASS as it is reserved in %s on line %d
New Features
http://php.net/manual/en/migration70.new-features.php
PHP7 NEW FEATURES
• Type declarations: bool, float, int, string
i)coercively
ii)strictly - declare(strict_types);
function sumOfInts(int $int, bool $bool, string $string){}
PHP7 NEW FEATURES
• Type declarations: bool, float, int, string
i)coercively
ii)strictly - declare(strict_types=1);
• Return type declarations === type_declarations
PHP7 NEW FEATURES
• Type declarations: bool, float, int, string
i)coercively
ii)strictly - declare(strict_types);
• Return type declarations === type_declarations
• Null coalesce operator
$username = $_GET['user'] ?? 'nobody';
// This is equivalent to:
$username = isset($_GET['user']) ? $_GET['user'] : 'nobody';
PHP7 NEW FEATURES
• Type declarations: bool, float, int, string
i)coercively
ii)strictly - declare(strict_types);
• Return type declarations === type_declarations
• Null coalesce operator
• Spaceship operator <=>
PHP7 NEW FEATURES
• Type declarations: bool, float, int, string
i)coercively
ii)strictly - declare(strict_types);
• Return type declarations === type_declarations
• Null coalesce operator
• Spaceship operator <=>
• Constant arrays using define()
<?php
define('ANIMALS', [
    'dog',
    'cat',
    'bird'
]);
echo ANIMALS[1]; // outputs "cat"
?>
PHP7 NEW FEATURES
• Type declarations: bool, float, int, string
i)coercively
ii)strictly - declare(strict_types);
• Return type declarations === type_declarations
• Null coalesce operator
• Spaceship operator <=>
• Constant arrays using define()
• Anonymous classes $var = new class implements Logger {
    public function log(string $msg) {
        echo $msg;
    }
};
PHP7 NEW FEATURES
• Type declarations: bool, float, int, string
i)coercively
ii)strictly - declare(strict_types);
• Return type declarations === type_declarations
• Null coalesce operator
• Spaceship operator <=>
• Constant arrays using define()
• Anonymous classes
• Filtered unserialize()
// converts all objects into __PHP_Incomplete_Class object except those of MyClass and MyClass2
$data = unserialize($foo, ["allowed_classes" => ["MyClass", "MyClass2"]);
PHP7 NEW FEATURES
• Type declarations: bool, float, int, string
i)coercively
ii)strictly - declare(strict_types);
• Return type declarations === type_declarations
• Null coalesce operator
• Spaceship operator <=>
• Constant arrays using define()
• Anonymous classes
• Filtered unserialize()
• Group use declarations
use somenamespace{ClassA, ClassB, ClassC as C};
PHP7 NEW FEATURES
• Type declarations: bool, float, int, string
i)coercively
ii)strictly - declare(strict_types);
• Return type declarations === type_declarations
• Null coalesce operator
• Spaceship operator <=>
• Constant arrays using define()
• Anonymous classes
• Filtered unserialize()
• Group use declarations
• Integer division with intdiv()
PHP7 NEW FEATURES
• Type declarations: bool, float, int, string
i)coercively
ii)strictly - declare(strict_types);
• Return type declarations === type_declarations
• Null coalesce operator
• Spaceship operator <=>
• Constant arrays using define()
• Anonymous classes
• Filtered unserialize()
• Group use declarations
• Integer division with intdiv()
• Fatal Errors to Exceptions
PHP7 NEW FEATURES
• Type declarations: bool, float, int, string
i)coercively
ii)strictly - declare(strict_types);
• Return type declarations === type_declarations
• Null coalesce operator
• Spaceship operator <=>
• Constant arrays using define()
• Anonymous classes
• Filtered unserialize()
• Group use declarations
• Integer division with intdiv()
• Fatal Errors to Exceptions
• Removal of date.timezone Warning
PHP7 NEW FEATURES
• Type declarations: bool, float, int, string
i)coercively
ii)strictly - declare(strict_types);
• Return type declarations === type_declarations
• Null coalesce operator
• Spaceship operator <=>
• Constant arrays using define()
• Anonymous classes
• Filtered unserialize()
• Group use declarations
• Integer division with intdiv()
• Fatal Errors to Exceptions
• Removal of date.timezone Warning
• Opcache: opcache.huge_code_pages=1 && opcache.file_cache
backward
compatibility
breakshttp://php.net/manual/en/migration70.incompatible.php
Old and new evaluation of indirect expressions
Expression PHP 5 interpretation PHP 7 interpretation
$$foo['bar']['baz'] ${$foo['bar']['baz']} ($$foo)['bar']['baz']
$foo->$bar['baz'] $foo->{$bar['baz']} ($foo->$bar)['baz']
$foo->$bar['baz']() $foo->{$bar['baz']}() ($foo->$bar)['baz']()
Foo::$bar['baz']() Foo::{$bar['baz']}() (Foo::$bar)['baz']()
foreach no longer a the internal array pointer
<?php
$array = [0, 1, 2];
foreach ($array as &$val) {
    var_dump(current($array));
}
?>
Output of the above example in PHP 5:
int(1)
int(2)
bool(false)
Output of the above example in PHP 7:
int(0)
int(0)
int(0)
foreach by-reference has improved iteration behaviour ¶
Output of the above example in PHP 5:
int(0)
Output of the above example in PHP 7:
int(0)
int(1)
<?php
$array = [0];
foreach ($array as &$val) {
    var_dump($val);
    $array[1] = 1;
}
?>
Changes to Division By Zero
Output of the above example in PHP 5:
Warning: Division by zero in
%s on line %d
bool(false)
Warning: Division by zero in
%s on line %d
bool(false)
Warning: Division by zero in
%s on line %d
bool(false)
<?php
var_dump(3/0); var_dump(0/0); var_dump(0%0);
?>
Output of the above example in PHP 7:
Warning: Division by zero in %s on line
%d
float(INF)
Warning: Division by zero in %s on line
%d
float(NAN)
PHP Fatal error: Uncaught
DivisionByZeroError: Modulo by zero in
%s line %d
$HTTP_RAW_POST_DATA removed
$HTTP_RAW_POST_DATA is no longer available. The php://input stream should be used instead.
JSON extension replaced with JSOND ¶
The JSON extension has been replaced with JSOND, causing two minor BC breaks.
Firstly, a number must not end in a decimal point
(i.e. 34. must be changed to either 34.0 or 34).
Secondly, when using scientific notation, the e exponent must not immediately follow a
decimal point (i.e. 3.e3 must be changed to either 3.0e3 or 3e3).
Compatibility Check
https://github.com/sstalle/php7cc
https://hub.docker.com/_/php/
TALK/SMOKE
TIME

More Related Content

What's hot

Peek at PHP 7
Peek at PHP 7Peek at PHP 7
Peek at PHP 7
John Coggeshall
 
Yapc::NA::2009 - Command Line Perl
Yapc::NA::2009 - Command Line PerlYapc::NA::2009 - Command Line Perl
Yapc::NA::2009 - Command Line Perl
Bruce Gray
 
Hacking with hhvm
Hacking with hhvmHacking with hhvm
Hacking with hhvm
Elizabeth Smith
 
Clojure beasts-euroclj-2014
Clojure beasts-euroclj-2014Clojure beasts-euroclj-2014
Clojure beasts-euroclj-2014
Renzo Borgatti
 
OSCON2014 : Quick Introduction to System Tools Programming with Go
OSCON2014 : Quick Introduction to System Tools Programming with GoOSCON2014 : Quick Introduction to System Tools Programming with Go
OSCON2014 : Quick Introduction to System Tools Programming with Go
Chris McEniry
 
What is Python Lambda Function? Python Tutorial | Edureka
What is Python Lambda Function? Python Tutorial | EdurekaWhat is Python Lambda Function? Python Tutorial | Edureka
What is Python Lambda Function? Python Tutorial | Edureka
Edureka!
 
Preparing code for Php 7 workshop
Preparing code for Php 7 workshopPreparing code for Php 7 workshop
Preparing code for Php 7 workshop
Damien Seguy
 
Triton and symbolic execution on gdb
Triton and symbolic execution on gdbTriton and symbolic execution on gdb
Triton and symbolic execution on gdb
Wei-Bo Chen
 
PHP 8.1 - What's new and changed
PHP 8.1 - What's new and changedPHP 8.1 - What's new and changed
PHP 8.1 - What's new and changed
Ayesh Karunaratne
 
Nikita Popov "What’s new in PHP 8.0?"
Nikita Popov "What’s new in PHP 8.0?"Nikita Popov "What’s new in PHP 8.0?"
Nikita Popov "What’s new in PHP 8.0?"
Fwdays
 
Learn To Test Like A Grumpy Programmer - 3 hour workshop
Learn To Test Like A Grumpy Programmer - 3 hour workshopLearn To Test Like A Grumpy Programmer - 3 hour workshop
Learn To Test Like A Grumpy Programmer - 3 hour workshop
chartjes
 
Java Full Throttle
Java Full ThrottleJava Full Throttle
Java Full Throttle
José Paumard
 
Why choose Hack/HHVM over PHP7
Why choose Hack/HHVM over PHP7Why choose Hack/HHVM over PHP7
Why choose Hack/HHVM over PHP7
Yuji Otani
 
PHP 8: Process & Fixing Insanity
PHP 8: Process & Fixing InsanityPHP 8: Process & Fixing Insanity
PHP 8: Process & Fixing Insanity
GeorgePeterBanyard
 
Programming in Computational Biology
Programming in Computational BiologyProgramming in Computational Biology
Programming in Computational Biology
AtreyiB
 
Php extensions
Php extensionsPhp extensions
Php extensions
Elizabeth Smith
 
Just-In-Time Compiler in PHP 8
Just-In-Time Compiler in PHP 8Just-In-Time Compiler in PHP 8
Just-In-Time Compiler in PHP 8
Nikita Popov
 
Go for SysAdmins - LISA 2015
Go for SysAdmins - LISA 2015Go for SysAdmins - LISA 2015
Go for SysAdmins - LISA 2015
Chris McEniry
 
Seeking Clojure
Seeking ClojureSeeking Clojure
Seeking Clojure
chrisriceuk
 
Memory Management In Python The Basics
Memory Management In Python The BasicsMemory Management In Python The Basics
Memory Management In Python The Basics
Nina Zakharenko
 

What's hot (20)

Peek at PHP 7
Peek at PHP 7Peek at PHP 7
Peek at PHP 7
 
Yapc::NA::2009 - Command Line Perl
Yapc::NA::2009 - Command Line PerlYapc::NA::2009 - Command Line Perl
Yapc::NA::2009 - Command Line Perl
 
Hacking with hhvm
Hacking with hhvmHacking with hhvm
Hacking with hhvm
 
Clojure beasts-euroclj-2014
Clojure beasts-euroclj-2014Clojure beasts-euroclj-2014
Clojure beasts-euroclj-2014
 
OSCON2014 : Quick Introduction to System Tools Programming with Go
OSCON2014 : Quick Introduction to System Tools Programming with GoOSCON2014 : Quick Introduction to System Tools Programming with Go
OSCON2014 : Quick Introduction to System Tools Programming with Go
 
What is Python Lambda Function? Python Tutorial | Edureka
What is Python Lambda Function? Python Tutorial | EdurekaWhat is Python Lambda Function? Python Tutorial | Edureka
What is Python Lambda Function? Python Tutorial | Edureka
 
Preparing code for Php 7 workshop
Preparing code for Php 7 workshopPreparing code for Php 7 workshop
Preparing code for Php 7 workshop
 
Triton and symbolic execution on gdb
Triton and symbolic execution on gdbTriton and symbolic execution on gdb
Triton and symbolic execution on gdb
 
PHP 8.1 - What's new and changed
PHP 8.1 - What's new and changedPHP 8.1 - What's new and changed
PHP 8.1 - What's new and changed
 
Nikita Popov "What’s new in PHP 8.0?"
Nikita Popov "What’s new in PHP 8.0?"Nikita Popov "What’s new in PHP 8.0?"
Nikita Popov "What’s new in PHP 8.0?"
 
Learn To Test Like A Grumpy Programmer - 3 hour workshop
Learn To Test Like A Grumpy Programmer - 3 hour workshopLearn To Test Like A Grumpy Programmer - 3 hour workshop
Learn To Test Like A Grumpy Programmer - 3 hour workshop
 
Java Full Throttle
Java Full ThrottleJava Full Throttle
Java Full Throttle
 
Why choose Hack/HHVM over PHP7
Why choose Hack/HHVM over PHP7Why choose Hack/HHVM over PHP7
Why choose Hack/HHVM over PHP7
 
PHP 8: Process & Fixing Insanity
PHP 8: Process & Fixing InsanityPHP 8: Process & Fixing Insanity
PHP 8: Process & Fixing Insanity
 
Programming in Computational Biology
Programming in Computational BiologyProgramming in Computational Biology
Programming in Computational Biology
 
Php extensions
Php extensionsPhp extensions
Php extensions
 
Just-In-Time Compiler in PHP 8
Just-In-Time Compiler in PHP 8Just-In-Time Compiler in PHP 8
Just-In-Time Compiler in PHP 8
 
Go for SysAdmins - LISA 2015
Go for SysAdmins - LISA 2015Go for SysAdmins - LISA 2015
Go for SysAdmins - LISA 2015
 
Seeking Clojure
Seeking ClojureSeeking Clojure
Seeking Clojure
 
Memory Management In Python The Basics
Memory Management In Python The BasicsMemory Management In Python The Basics
Memory Management In Python The Basics
 

Viewers also liked

Migrating to php7
Migrating to php7Migrating to php7
Migrating to php7
Richard Prillwitz
 
Integrating React.js Into a PHP Application
Integrating React.js Into a PHP ApplicationIntegrating React.js Into a PHP Application
Integrating React.js Into a PHP Application
Andrew Rota
 
Object oriented programming in php 5
Object oriented programming in php 5Object oriented programming in php 5
Object oriented programming in php 5
Sayed Ahmed
 
Fundamento de poo en php
Fundamento de poo en phpFundamento de poo en php
Fundamento de poo en php
Robert Moreira
 
What’s New in PHP7?
What’s New in PHP7?What’s New in PHP7?
What’s New in PHP7?
GlobalLogic Ukraine
 
Introduce php7
Introduce php7Introduce php7
Introduce php7
Jung soo Ahn
 
PHP7 e Rich Domain Model
PHP7 e Rich Domain ModelPHP7 e Rich Domain Model
PHP7 e Rich Domain Model
Massimiliano Arione
 
Continuous Quality Assurance
Continuous Quality AssuranceContinuous Quality Assurance
Continuous Quality Assurance
Michelangelo van Dam
 
The promise of asynchronous PHP
The promise of asynchronous PHPThe promise of asynchronous PHP
The promise of asynchronous PHP
Wim Godden
 
A new way to develop with WordPress!
A new way to develop with WordPress!A new way to develop with WordPress!
A new way to develop with WordPress!
David Sanchez
 
PHP7 Presentation
PHP7 PresentationPHP7 Presentation
PHP7 Presentation
David Sanchez
 
PHP 7
PHP 7PHP 7
reveal.js 3.0.0
reveal.js 3.0.0reveal.js 3.0.0
reveal.js 3.0.0
Hakim El Hattab
 
Creating HTML Pages
Creating HTML PagesCreating HTML Pages
Creating HTML Pages
Mike Crabb
 
Top Insights from SaaStr by Leading Enterprise Software Experts
Top Insights from SaaStr by Leading Enterprise Software ExpertsTop Insights from SaaStr by Leading Enterprise Software Experts
Top Insights from SaaStr by Leading Enterprise Software Experts
OpenView
 
Test Automation - Principles and Practices
Test Automation - Principles and PracticesTest Automation - Principles and Practices
Test Automation - Principles and Practices
Anand Bagmar
 
CSS Grid Layout for Topconf, Linz
CSS Grid Layout for Topconf, LinzCSS Grid Layout for Topconf, Linz
CSS Grid Layout for Topconf, Linz
Rachel Andrew
 
New Amazing Things about AngularJS 2.0
New Amazing Things about AngularJS 2.0New Amazing Things about AngularJS 2.0
New Amazing Things about AngularJS 2.0
Mike Taylor
 
Node.js and The Internet of Things
Node.js and The Internet of ThingsNode.js and The Internet of Things
Node.js and The Internet of Things
Losant
 
The Future of Real-Time in Spark
The Future of Real-Time in SparkThe Future of Real-Time in Spark
The Future of Real-Time in Spark
Reynold Xin
 

Viewers also liked (20)

Migrating to php7
Migrating to php7Migrating to php7
Migrating to php7
 
Integrating React.js Into a PHP Application
Integrating React.js Into a PHP ApplicationIntegrating React.js Into a PHP Application
Integrating React.js Into a PHP Application
 
Object oriented programming in php 5
Object oriented programming in php 5Object oriented programming in php 5
Object oriented programming in php 5
 
Fundamento de poo en php
Fundamento de poo en phpFundamento de poo en php
Fundamento de poo en php
 
What’s New in PHP7?
What’s New in PHP7?What’s New in PHP7?
What’s New in PHP7?
 
Introduce php7
Introduce php7Introduce php7
Introduce php7
 
PHP7 e Rich Domain Model
PHP7 e Rich Domain ModelPHP7 e Rich Domain Model
PHP7 e Rich Domain Model
 
Continuous Quality Assurance
Continuous Quality AssuranceContinuous Quality Assurance
Continuous Quality Assurance
 
The promise of asynchronous PHP
The promise of asynchronous PHPThe promise of asynchronous PHP
The promise of asynchronous PHP
 
A new way to develop with WordPress!
A new way to develop with WordPress!A new way to develop with WordPress!
A new way to develop with WordPress!
 
PHP7 Presentation
PHP7 PresentationPHP7 Presentation
PHP7 Presentation
 
PHP 7
PHP 7PHP 7
PHP 7
 
reveal.js 3.0.0
reveal.js 3.0.0reveal.js 3.0.0
reveal.js 3.0.0
 
Creating HTML Pages
Creating HTML PagesCreating HTML Pages
Creating HTML Pages
 
Top Insights from SaaStr by Leading Enterprise Software Experts
Top Insights from SaaStr by Leading Enterprise Software ExpertsTop Insights from SaaStr by Leading Enterprise Software Experts
Top Insights from SaaStr by Leading Enterprise Software Experts
 
Test Automation - Principles and Practices
Test Automation - Principles and PracticesTest Automation - Principles and Practices
Test Automation - Principles and Practices
 
CSS Grid Layout for Topconf, Linz
CSS Grid Layout for Topconf, LinzCSS Grid Layout for Topconf, Linz
CSS Grid Layout for Topconf, Linz
 
New Amazing Things about AngularJS 2.0
New Amazing Things about AngularJS 2.0New Amazing Things about AngularJS 2.0
New Amazing Things about AngularJS 2.0
 
Node.js and The Internet of Things
Node.js and The Internet of ThingsNode.js and The Internet of Things
Node.js and The Internet of Things
 
The Future of Real-Time in Spark
The Future of Real-Time in SparkThe Future of Real-Time in Spark
The Future of Real-Time in Spark
 

Similar to PHP7: Hello World!

What To Expect From PHP7
What To Expect From PHP7What To Expect From PHP7
What To Expect From PHP7
Codemotion
 
Migrating to PHP 7
Migrating to PHP 7Migrating to PHP 7
Migrating to PHP 7
John Coggeshall
 
Materi Dasar PHP
Materi Dasar PHPMateri Dasar PHP
Materi Dasar PHP
Robby Firmansyah
 
Php 7 compliance workshop singapore
Php 7 compliance workshop singaporePhp 7 compliance workshop singapore
Php 7 compliance workshop singapore
Damien Seguy
 
The why and how of moving to php 5.4
The why and how of moving to php 5.4The why and how of moving to php 5.4
The why and how of moving to php 5.4
Wim Godden
 
Php7 傳說中的第七隻大象
Php7 傳說中的第七隻大象Php7 傳說中的第七隻大象
Php7 傳說中的第七隻大象
bobo52310
 
Hsc IT 5. Server-Side Scripting (PHP).pdf
Hsc IT 5. Server-Side Scripting (PHP).pdfHsc IT 5. Server-Side Scripting (PHP).pdf
Hsc IT 5. Server-Side Scripting (PHP).pdf
AAFREEN SHAIKH
 
Php training100%placement-in-mumbai
Php training100%placement-in-mumbaiPhp training100%placement-in-mumbai
Php training100%placement-in-mumbai
vibrantuser
 
HHVM and Hack: A quick introduction
HHVM and Hack: A quick introductionHHVM and Hack: A quick introduction
HHVM and Hack: A quick introduction
Kuan Yen Heng
 
Php 5.6 vs Php 7 performance comparison
Php 5.6 vs Php 7 performance comparisonPhp 5.6 vs Php 7 performance comparison
Php 5.6 vs Php 7 performance comparison
Tu Pham
 
PHP 7X New Features
PHP 7X New FeaturesPHP 7X New Features
PHP 7X New Features
Thanh Tai
 
Introduction to php basics
Introduction to php   basicsIntroduction to php   basics
Php1
Php1Php1
TAKING PHP SERIOUSLY - Keith Adams
TAKING PHP SERIOUSLY - Keith AdamsTAKING PHP SERIOUSLY - Keith Adams
TAKING PHP SERIOUSLY - Keith Adams
Hermes Alves
 
PHP from soup to nuts Course Deck
PHP from soup to nuts Course DeckPHP from soup to nuts Course Deck
PHP from soup to nuts Course Deck
rICh morrow
 
The why and how of moving to php 7
The why and how of moving to php 7The why and how of moving to php 7
The why and how of moving to php 7
Wim Godden
 
PHP 7.0 new features (and new interpreter)
PHP 7.0 new features (and new interpreter)PHP 7.0 new features (and new interpreter)
PHP 7.0 new features (and new interpreter)
Andrea Telatin
 
50 shades of PHP
50 shades of PHP50 shades of PHP
50 shades of PHP
Maksym Hopei
 
Static Analysis of PHP Code – IPC Berlin 2016
Static Analysis of PHP Code – IPC Berlin 2016Static Analysis of PHP Code – IPC Berlin 2016
Static Analysis of PHP Code – IPC Berlin 2016
Rouven Weßling
 
PHP7.1 New Features & Performance
PHP7.1 New Features & PerformancePHP7.1 New Features & Performance
PHP7.1 New Features & Performance
Xinchen Hui
 

Similar to PHP7: Hello World! (20)

What To Expect From PHP7
What To Expect From PHP7What To Expect From PHP7
What To Expect From PHP7
 
Migrating to PHP 7
Migrating to PHP 7Migrating to PHP 7
Migrating to PHP 7
 
Materi Dasar PHP
Materi Dasar PHPMateri Dasar PHP
Materi Dasar PHP
 
Php 7 compliance workshop singapore
Php 7 compliance workshop singaporePhp 7 compliance workshop singapore
Php 7 compliance workshop singapore
 
The why and how of moving to php 5.4
The why and how of moving to php 5.4The why and how of moving to php 5.4
The why and how of moving to php 5.4
 
Php7 傳說中的第七隻大象
Php7 傳說中的第七隻大象Php7 傳說中的第七隻大象
Php7 傳說中的第七隻大象
 
Hsc IT 5. Server-Side Scripting (PHP).pdf
Hsc IT 5. Server-Side Scripting (PHP).pdfHsc IT 5. Server-Side Scripting (PHP).pdf
Hsc IT 5. Server-Side Scripting (PHP).pdf
 
Php training100%placement-in-mumbai
Php training100%placement-in-mumbaiPhp training100%placement-in-mumbai
Php training100%placement-in-mumbai
 
HHVM and Hack: A quick introduction
HHVM and Hack: A quick introductionHHVM and Hack: A quick introduction
HHVM and Hack: A quick introduction
 
Php 5.6 vs Php 7 performance comparison
Php 5.6 vs Php 7 performance comparisonPhp 5.6 vs Php 7 performance comparison
Php 5.6 vs Php 7 performance comparison
 
PHP 7X New Features
PHP 7X New FeaturesPHP 7X New Features
PHP 7X New Features
 
Introduction to php basics
Introduction to php   basicsIntroduction to php   basics
Introduction to php basics
 
Php1
Php1Php1
Php1
 
TAKING PHP SERIOUSLY - Keith Adams
TAKING PHP SERIOUSLY - Keith AdamsTAKING PHP SERIOUSLY - Keith Adams
TAKING PHP SERIOUSLY - Keith Adams
 
PHP from soup to nuts Course Deck
PHP from soup to nuts Course DeckPHP from soup to nuts Course Deck
PHP from soup to nuts Course Deck
 
The why and how of moving to php 7
The why and how of moving to php 7The why and how of moving to php 7
The why and how of moving to php 7
 
PHP 7.0 new features (and new interpreter)
PHP 7.0 new features (and new interpreter)PHP 7.0 new features (and new interpreter)
PHP 7.0 new features (and new interpreter)
 
50 shades of PHP
50 shades of PHP50 shades of PHP
50 shades of PHP
 
Static Analysis of PHP Code – IPC Berlin 2016
Static Analysis of PHP Code – IPC Berlin 2016Static Analysis of PHP Code – IPC Berlin 2016
Static Analysis of PHP Code – IPC Berlin 2016
 
PHP7.1 New Features & Performance
PHP7.1 New Features & PerformancePHP7.1 New Features & Performance
PHP7.1 New Features & Performance
 

Recently uploaded

GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
Green Software Development
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
Hornet Dynamics
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Crescat
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Łukasz Chruściel
 
What is Augmented Reality Image Tracking
What is Augmented Reality Image TrackingWhat is Augmented Reality Image Tracking
What is Augmented Reality Image Tracking
pavan998932
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
ICS
 
Empowering Growth with Best Software Development Company in Noida - Deuglo
Empowering Growth with Best Software  Development Company in Noida - DeugloEmpowering Growth with Best Software  Development Company in Noida - Deuglo
Empowering Growth with Best Software Development Company in Noida - Deuglo
Deuglo Infosystem Pvt Ltd
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
Google
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
Łukasz Chruściel
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
Peter Muessig
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
mz5nrf0n
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
Philip Schwarz
 
SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024
Hironori Washizaki
 
DDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systemsDDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systems
Gerardo Pardo-Castellote
 
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise EditionWhy Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
Envertis Software Solutions
 
Unveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdfUnveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdf
brainerhub1
 
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Julian Hyde
 
socradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdfsocradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdf
SOCRadar
 
How to write a program in any programming language
How to write a program in any programming languageHow to write a program in any programming language
How to write a program in any programming language
Rakesh Kumar R
 

Recently uploaded (20)

GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
 
What is Augmented Reality Image Tracking
What is Augmented Reality Image TrackingWhat is Augmented Reality Image Tracking
What is Augmented Reality Image Tracking
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
 
Empowering Growth with Best Software Development Company in Noida - Deuglo
Empowering Growth with Best Software  Development Company in Noida - DeugloEmpowering Growth with Best Software  Development Company in Noida - Deuglo
Empowering Growth with Best Software Development Company in Noida - Deuglo
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
 
SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024
 
DDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systemsDDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systems
 
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise EditionWhy Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
 
Unveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdfUnveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdf
 
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)
 
socradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdfsocradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdf
 
How to write a program in any programming language
How to write a program in any programming languageHow to write a program in any programming language
How to write a program in any programming language
 

PHP7: Hello World!

  • 2.
  • 3. Who The Fuck Is This Guy? Pavel Nikolov
  • 4. Pavel Nikolov @pavkatar
 CEO at ApiHawk Technologies, Geek, API Evangelist. iLover, Developer, Coffee drinker and just an irregular person Sofia, Bulgaria
  • 6. Version Release Lifetime Personal Homepage Tools (PHP tools) v.1 June 8, 1995 ~ 2 years PHPFI (Form Interpreter) v2 November 1997 ~ 1 year PHP3 June 1998 ~ 2 years PHP4 May 2000 ~ 4 years PHP5 July 2004 ~ 11 years PHP5.3 (PHP 6 - Unicode) June 2009 PHP7 Fall 2015 2015 - 20 Years of PHP
  • 7. PHP7 CHANGES “UNDER THE HOOD”
  • 8. PHP Version 5.3 5.4 5.5 5.6 7 Interations per second 282544 278205 304330 301689 583975 288611 268948 307818 308273 603583 288517 279900 296669 301989 606468 282384 282060 299921 308735 596079 288162 280692 298747 308003 610696 286300 278374 307043 303139 594547 291027 278703 305950 311487 602184 292292 282226 296287 312770 610380 Average 287480 278639 302096 307011 600989 Percentage faster than previous version N/A -3.08% 8.42% 1.63% 95.76% Executor: Faster
  • 9. Executor: Less Memory 32 bit 64 bit PHP 5.6 7.37 MiB 13.97 MiB PHP 7.0 3.00 MiB 4.00 MiB $startMemory = memory_get_usage(); $array = range(1, 100000); echo memory_get_usage() - $startMemory, " bytesn";
  • 10. PHP7 CHANGES “UNDER THE HOOD” • Executor: Faster • Executor: Less memory • Compiler: Generates better bytecode
  • 11. PHP7 CHANGES “UNDER THE HOOD” • Executor: Faster • Executor: Less memory • Compiler: Generates better bytecode • Parser: Now based on AST (abstract syntax tree)
  • 12. PHP7 CHANGES “UNDER THE HOOD” • Executor: Faster • Executor: Less memory • Compiler: Generates better bytecode • Parser: Now based on AST (abstract syntax tree) • Lexer: Now contex-sensitive with support for semi-reserved words class Collection { public function forEach(callable $callback) { /* */ } public function list() { /* */ } }
  • 13. PHP7 CHANGES “UNDER THE HOOD” • Executor: Faster • Executor: Less memory • Compiler: Generates better bytecode • Parser: Now based on AST (abstract syntax tree) • Lexer: Now contex-sensitive with support for semi-reserved words PHP5.6: PHP Parse error: Syntax error, unexpected T_FOREACH, expecting T_STRING on line 2 PHP Parse error: Syntax error, unexpected T_LIST, expecting T_STRING on line 3
  • 14. callable class trait extends implements static abstract final public protected private const enddeclare endfor endforeach endif endwhile and global goto instanceof insteadof interface namespace new or xor try use var exit list clone include include_once throw array print echo require require_once return else elseif default break continue switch yield function if endswitch finally for foreach declare case do while as catch die self parent This is a list of currently globally reserved words that will become semi-reserved in case proposed change gets approved:
  • 15. PHP7 CHANGES “UNDER THE HOOD” Limitation! It's still forbidden to define a class constant named as class because of the class name resolution ::class: In practice, it means that we would drop from 64 to only 1 reserved word that affects only class constant names. class Foo { const class = 'Foo'; // Fatal error }   // Fatal error: Cannot redefine class constant Foo::CLASS as it is reserved in %s on line %d
  • 17. PHP7 NEW FEATURES • Type declarations: bool, float, int, string i)coercively ii)strictly - declare(strict_types); function sumOfInts(int $int, bool $bool, string $string){}
  • 18. PHP7 NEW FEATURES • Type declarations: bool, float, int, string i)coercively ii)strictly - declare(strict_types=1); • Return type declarations === type_declarations
  • 19. PHP7 NEW FEATURES • Type declarations: bool, float, int, string i)coercively ii)strictly - declare(strict_types); • Return type declarations === type_declarations • Null coalesce operator $username = $_GET['user'] ?? 'nobody'; // This is equivalent to: $username = isset($_GET['user']) ? $_GET['user'] : 'nobody';
  • 20. PHP7 NEW FEATURES • Type declarations: bool, float, int, string i)coercively ii)strictly - declare(strict_types); • Return type declarations === type_declarations • Null coalesce operator • Spaceship operator <=>
  • 21. PHP7 NEW FEATURES • Type declarations: bool, float, int, string i)coercively ii)strictly - declare(strict_types); • Return type declarations === type_declarations • Null coalesce operator • Spaceship operator <=> • Constant arrays using define() <?php define('ANIMALS', [     'dog',     'cat',     'bird' ]); echo ANIMALS[1]; // outputs "cat" ?>
  • 22. PHP7 NEW FEATURES • Type declarations: bool, float, int, string i)coercively ii)strictly - declare(strict_types); • Return type declarations === type_declarations • Null coalesce operator • Spaceship operator <=> • Constant arrays using define() • Anonymous classes $var = new class implements Logger {     public function log(string $msg) {         echo $msg;     } };
  • 23. PHP7 NEW FEATURES • Type declarations: bool, float, int, string i)coercively ii)strictly - declare(strict_types); • Return type declarations === type_declarations • Null coalesce operator • Spaceship operator <=> • Constant arrays using define() • Anonymous classes • Filtered unserialize() // converts all objects into __PHP_Incomplete_Class object except those of MyClass and MyClass2 $data = unserialize($foo, ["allowed_classes" => ["MyClass", "MyClass2"]);
  • 24. PHP7 NEW FEATURES • Type declarations: bool, float, int, string i)coercively ii)strictly - declare(strict_types); • Return type declarations === type_declarations • Null coalesce operator • Spaceship operator <=> • Constant arrays using define() • Anonymous classes • Filtered unserialize() • Group use declarations use somenamespace{ClassA, ClassB, ClassC as C};
  • 25. PHP7 NEW FEATURES • Type declarations: bool, float, int, string i)coercively ii)strictly - declare(strict_types); • Return type declarations === type_declarations • Null coalesce operator • Spaceship operator <=> • Constant arrays using define() • Anonymous classes • Filtered unserialize() • Group use declarations • Integer division with intdiv()
  • 26. PHP7 NEW FEATURES • Type declarations: bool, float, int, string i)coercively ii)strictly - declare(strict_types); • Return type declarations === type_declarations • Null coalesce operator • Spaceship operator <=> • Constant arrays using define() • Anonymous classes • Filtered unserialize() • Group use declarations • Integer division with intdiv() • Fatal Errors to Exceptions
  • 27. PHP7 NEW FEATURES • Type declarations: bool, float, int, string i)coercively ii)strictly - declare(strict_types); • Return type declarations === type_declarations • Null coalesce operator • Spaceship operator <=> • Constant arrays using define() • Anonymous classes • Filtered unserialize() • Group use declarations • Integer division with intdiv() • Fatal Errors to Exceptions • Removal of date.timezone Warning
  • 28. PHP7 NEW FEATURES • Type declarations: bool, float, int, string i)coercively ii)strictly - declare(strict_types); • Return type declarations === type_declarations • Null coalesce operator • Spaceship operator <=> • Constant arrays using define() • Anonymous classes • Filtered unserialize() • Group use declarations • Integer division with intdiv() • Fatal Errors to Exceptions • Removal of date.timezone Warning • Opcache: opcache.huge_code_pages=1 && opcache.file_cache
  • 30. Old and new evaluation of indirect expressions Expression PHP 5 interpretation PHP 7 interpretation $$foo['bar']['baz'] ${$foo['bar']['baz']} ($$foo)['bar']['baz'] $foo->$bar['baz'] $foo->{$bar['baz']} ($foo->$bar)['baz'] $foo->$bar['baz']() $foo->{$bar['baz']}() ($foo->$bar)['baz']() Foo::$bar['baz']() Foo::{$bar['baz']}() (Foo::$bar)['baz']()
  • 31. foreach no longer a the internal array pointer <?php $array = [0, 1, 2]; foreach ($array as &$val) {     var_dump(current($array)); } ?> Output of the above example in PHP 5: int(1) int(2) bool(false) Output of the above example in PHP 7: int(0) int(0) int(0)
  • 32. foreach by-reference has improved iteration behaviour ¶ Output of the above example in PHP 5: int(0) Output of the above example in PHP 7: int(0) int(1) <?php $array = [0]; foreach ($array as &$val) {     var_dump($val);     $array[1] = 1; } ?>
  • 33. Changes to Division By Zero Output of the above example in PHP 5: Warning: Division by zero in %s on line %d bool(false) Warning: Division by zero in %s on line %d bool(false) Warning: Division by zero in %s on line %d bool(false) <?php var_dump(3/0); var_dump(0/0); var_dump(0%0); ?> Output of the above example in PHP 7: Warning: Division by zero in %s on line %d float(INF) Warning: Division by zero in %s on line %d float(NAN) PHP Fatal error: Uncaught DivisionByZeroError: Modulo by zero in %s line %d
  • 34. $HTTP_RAW_POST_DATA removed $HTTP_RAW_POST_DATA is no longer available. The php://input stream should be used instead.
  • 35. JSON extension replaced with JSOND ¶ The JSON extension has been replaced with JSOND, causing two minor BC breaks. Firstly, a number must not end in a decimal point (i.e. 34. must be changed to either 34.0 or 34). Secondly, when using scientific notation, the e exponent must not immediately follow a decimal point (i.e. 3.e3 must be changed to either 3.0e3 or 3e3).