SlideShare a Scribd company logo
1 of 17
Download to read offline
What’s new in PHP 7.1
And why you really shouldn’t be using PHP5 anymore…
PHP Cambridge, 12th December 2016
Simon Jones, Studio 24
PHP 7.1
• Released 1st Dec 2017
• PHP 5.6 end of life 31 Dec 2018
• PHP 5.4 and 5.5 no longer supported
• WordPress now recommends PHP 7 

(though still works on PHP 5.2

which was released over.. Nine. Years. Ago!)
Supported versions of PHP
http://php.net/supported-versions.php
Why PHP 7?
• Current, stable & supported version of PHP
• Stricter, more secure, and faster!
• Twice as fast for most applications
• Reduced memory usage
http://talks.php.net/fluent15#/wpbench
New features
PHP 5.5
password_hash()

Generators

Zend Optimiser+ opcode cache (OPcache)
PHP 5.6
Constant expressions
Variadic functions (...$params)
PHP 7.0
Scalar type, return type declarations
Exception hierarchy
Spaceship operator <=>
PHP 7.1
Class constant visibility

Nullable types, void return type, iterable pseudo-type
Multi catch exception handling
• Removed from PHP..
• mysql_* functions (use PDO)
• mssql_* functions (use PDO)
• ereg_* functions (use preg_*)
• ASP & script style tags 

<% %> 

<script language=“php”> </script>
• foreach no longer changes the internal array pointer
What breaks / changes in PHP 7.0?
• Error exception thrown when invoking user-defined
functions with too few arguments



function hello($name, $age) { }

echo hello("Simon");
• DateTime constructor includes microseconds, 

be careful when comparing:



new DateTime() == new DateTime();
What breaks / changes in PHP 7.1?
Going, going…
• PHP 4 style constructors



class MyClass {

function MyClass() {}

}
• Static calls to non-static methods



class MyClass {

public function print() {}

}

MyClass::print();
Two new features

Error exceptions & type hinting
• Fatal errors throw exceptions. Yay!
• Custom error handlers may no longer work
Changes to error handling
http://php.net/manual/en/language.errors.php7.php
Type hinting
Scalar type hinting

function hello (string $name, int $age) {

echo "Hello $name, you are nearly " . $age + 1;

}
Return types

function hello (string $name, int $age) : string {

return "Hello $name, you are nearly " . $age + 1;

}
Strict typing
By default, PHP will coerce values of the wrong type into
the expected scalar type if possible. 

function hello (string $name, int $age) { 

echo "Hello $name, you are nearly " . $age + 1;

}

This is OK

hello("Simon", "42");
Strict typing
Unless you enable strict mode

declare(strict_types=1);

function hello (string $name, int $age) { 

echo "Hello $name, you are nearly " . $age + 1;

}
This throws a Fatal error exception

hello("Simon", "42");
Type hinting..
PHP 5.0
Class Name

self
PHP 5.1 array
PHP 5.4 callable
PHP 7.0
bool
float
int
string
PHP 7.1
iterable (array or Traversable)

Nullable types, e.g. ?string
void return type
Migration
• Upgrade to PHP5.6
• Then PHP7
• Migration guides:

http://php.net/manual/en/migration56.php

http://php.net/manual/en/migration70.php

http://php.net/manual/en/migration71.php
Thanks!

More Related Content

What's hot

Loops PHP 04
Loops PHP 04Loops PHP 04
Loops PHP 04Spy Seat
 
Php introduction and configuration
Php introduction and configurationPhp introduction and configuration
Php introduction and configurationVijay Kumar Verma
 
BDD style Unit Testing
BDD style Unit TestingBDD style Unit Testing
BDD style Unit TestingWen-Tien Chang
 
Chapter 02 php basic syntax
Chapter 02   php basic syntaxChapter 02   php basic syntax
Chapter 02 php basic syntaxDhani Ahmad
 
Automating Your Daily Tasks with Scripting - RubyConf 2015 Taiwan
Automating Your Daily Tasks with Scripting - RubyConf 2015 TaiwanAutomating Your Daily Tasks with Scripting - RubyConf 2015 Taiwan
Automating Your Daily Tasks with Scripting - RubyConf 2015 TaiwanAdler Hsieh
 
Ruby Basics
Ruby BasicsRuby Basics
Ruby BasicsSHC
 
Php(report)
Php(report)Php(report)
Php(report)Yhannah
 
10 Groovy Little JavaScript Tips
10 Groovy Little JavaScript Tips10 Groovy Little JavaScript Tips
10 Groovy Little JavaScript TipsTroy Miles
 
Coldfusion
ColdfusionColdfusion
ColdfusionRam
 

What's hot (17)

Loops PHP 04
Loops PHP 04Loops PHP 04
Loops PHP 04
 
Introduction to php php++
Introduction to php php++Introduction to php php++
Introduction to php php++
 
Php introduction and configuration
Php introduction and configurationPhp introduction and configuration
Php introduction and configuration
 
PHP
PHPPHP
PHP
 
Php mysql
Php mysqlPhp mysql
Php mysql
 
Php Tutorial
Php TutorialPhp Tutorial
Php Tutorial
 
BDD style Unit Testing
BDD style Unit TestingBDD style Unit Testing
BDD style Unit Testing
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 
Php
PhpPhp
Php
 
Chapter 02 php basic syntax
Chapter 02   php basic syntaxChapter 02   php basic syntax
Chapter 02 php basic syntax
 
Wt unit 5
Wt unit 5Wt unit 5
Wt unit 5
 
Automating Your Daily Tasks with Scripting - RubyConf 2015 Taiwan
Automating Your Daily Tasks with Scripting - RubyConf 2015 TaiwanAutomating Your Daily Tasks with Scripting - RubyConf 2015 Taiwan
Automating Your Daily Tasks with Scripting - RubyConf 2015 Taiwan
 
Ruby Basics
Ruby BasicsRuby Basics
Ruby Basics
 
RubyMotion #jbday
RubyMotion #jbdayRubyMotion #jbday
RubyMotion #jbday
 
Php(report)
Php(report)Php(report)
Php(report)
 
10 Groovy Little JavaScript Tips
10 Groovy Little JavaScript Tips10 Groovy Little JavaScript Tips
10 Groovy Little JavaScript Tips
 
Coldfusion
ColdfusionColdfusion
Coldfusion
 

Viewers also liked (20)

OOPS Characteristics (With Examples in PHP)
OOPS Characteristics (With Examples in PHP)OOPS Characteristics (With Examples in PHP)
OOPS Characteristics (With Examples in PHP)
 
PHP variables
PHP  variablesPHP  variables
PHP variables
 
Speed up your site with Varnish
Speed up your site with VarnishSpeed up your site with Varnish
Speed up your site with Varnish
 
What we look for 
in people when recruiting
What we look for 
in people when recruitingWhat we look for 
in people when recruiting
What we look for 
in people when recruiting
 
Modern PHP
Modern PHPModern PHP
Modern PHP
 
PHP Presentation
PHP PresentationPHP Presentation
PHP Presentation
 
Font
FontFont
Font
 
Php variables (english)
Php variables (english)Php variables (english)
Php variables (english)
 
Control Structures In Php 2
Control Structures In Php 2Control Structures In Php 2
Control Structures In Php 2
 
Htmltag.ppt
Htmltag.pptHtmltag.ppt
Htmltag.ppt
 
Php ppt
Php pptPhp ppt
Php ppt
 
Arrays in PHP
Arrays in PHPArrays in PHP
Arrays in PHP
 
Execute MySQL query using command prompt
Execute MySQL query using command promptExecute MySQL query using command prompt
Execute MySQL query using command prompt
 
Form Processing In Php
Form Processing In PhpForm Processing In Php
Form Processing In Php
 
State management
State managementState management
State management
 
Execute sql query or sql command sql server using command prompt
Execute sql query or sql command sql server using command promptExecute sql query or sql command sql server using command prompt
Execute sql query or sql command sql server using command prompt
 
Php forms
Php formsPhp forms
Php forms
 
Php tutorial
Php tutorialPhp tutorial
Php tutorial
 
Regular Expressions in PHP
Regular Expressions in PHPRegular Expressions in PHP
Regular Expressions in PHP
 
PHP Summer Training Presentation
PHP Summer Training PresentationPHP Summer Training Presentation
PHP Summer Training Presentation
 

Similar to What's new in PHP 7.1

Similar to What's new in PHP 7.1 (20)

TAKING PHP SERIOUSLY - Keith Adams
TAKING PHP SERIOUSLY - Keith AdamsTAKING PHP SERIOUSLY - Keith Adams
TAKING PHP SERIOUSLY - Keith Adams
 
What To Expect From PHP7
What To Expect From PHP7What To Expect From PHP7
What To Expect From PHP7
 
Basics PHP
Basics PHPBasics PHP
Basics PHP
 
Preparing code for Php 7 workshop
Preparing code for Php 7 workshopPreparing code for Php 7 workshop
Preparing code for Php 7 workshop
 
Php7 傳說中的第七隻大象
Php7 傳說中的第七隻大象Php7 傳說中的第七隻大象
Php7 傳說中的第七隻大象
 
Peek at PHP 7
Peek at PHP 7Peek at PHP 7
Peek at PHP 7
 
Php7 HHVM and co
Php7 HHVM and coPhp7 HHVM and co
Php7 HHVM and co
 
Migrating to PHP 7
Migrating to PHP 7Migrating to PHP 7
Migrating to PHP 7
 
Upstate CSCI 450 PHP Chapters 5, 12, 13
Upstate CSCI 450 PHP Chapters 5, 12, 13Upstate CSCI 450 PHP Chapters 5, 12, 13
Upstate CSCI 450 PHP Chapters 5, 12, 13
 
Start using PHP 7
Start using PHP 7Start using PHP 7
Start using PHP 7
 
Php7 hhvm and co
Php7 hhvm and coPhp7 hhvm and co
Php7 hhvm and co
 
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
 
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
 
01 basics
01 basics01 basics
01 basics
 
php basic
php basicphp basic
php basic
 
WT_PHP_PART1.pdf
WT_PHP_PART1.pdfWT_PHP_PART1.pdf
WT_PHP_PART1.pdf
 
PHP - Introduction to PHP Fundamentals
PHP -  Introduction to PHP FundamentalsPHP -  Introduction to PHP Fundamentals
PHP - Introduction to PHP Fundamentals
 
Prersentation
PrersentationPrersentation
Prersentation
 
50 shades of PHP
50 shades of PHP50 shades of PHP
50 shades of PHP
 
Php tutorial
Php tutorialPhp tutorial
Php tutorial
 

Recently uploaded

New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 

Recently uploaded (20)

New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 

What's new in PHP 7.1

  • 1. What’s new in PHP 7.1 And why you really shouldn’t be using PHP5 anymore… PHP Cambridge, 12th December 2016 Simon Jones, Studio 24
  • 2. PHP 7.1 • Released 1st Dec 2017 • PHP 5.6 end of life 31 Dec 2018 • PHP 5.4 and 5.5 no longer supported • WordPress now recommends PHP 7 
 (though still works on PHP 5.2
 which was released over.. Nine. Years. Ago!)
  • 3. Supported versions of PHP http://php.net/supported-versions.php
  • 4. Why PHP 7? • Current, stable & supported version of PHP • Stricter, more secure, and faster! • Twice as fast for most applications • Reduced memory usage
  • 6. New features PHP 5.5 password_hash()
 Generators
 Zend Optimiser+ opcode cache (OPcache) PHP 5.6 Constant expressions Variadic functions (...$params) PHP 7.0 Scalar type, return type declarations Exception hierarchy Spaceship operator <=> PHP 7.1 Class constant visibility
 Nullable types, void return type, iterable pseudo-type Multi catch exception handling
  • 7. • Removed from PHP.. • mysql_* functions (use PDO) • mssql_* functions (use PDO) • ereg_* functions (use preg_*) • ASP & script style tags 
 <% %> 
 <script language=“php”> </script> • foreach no longer changes the internal array pointer What breaks / changes in PHP 7.0?
  • 8. • Error exception thrown when invoking user-defined functions with too few arguments
 
 function hello($name, $age) { }
 echo hello("Simon"); • DateTime constructor includes microseconds, 
 be careful when comparing:
 
 new DateTime() == new DateTime(); What breaks / changes in PHP 7.1?
  • 9. Going, going… • PHP 4 style constructors
 
 class MyClass {
 function MyClass() {}
 } • Static calls to non-static methods
 
 class MyClass {
 public function print() {}
 }
 MyClass::print();
  • 10. Two new features
 Error exceptions & type hinting
  • 11. • Fatal errors throw exceptions. Yay! • Custom error handlers may no longer work Changes to error handling http://php.net/manual/en/language.errors.php7.php
  • 12. Type hinting Scalar type hinting
 function hello (string $name, int $age) {
 echo "Hello $name, you are nearly " . $age + 1;
 } Return types
 function hello (string $name, int $age) : string {
 return "Hello $name, you are nearly " . $age + 1;
 }
  • 13. Strict typing By default, PHP will coerce values of the wrong type into the expected scalar type if possible. 
 function hello (string $name, int $age) { 
 echo "Hello $name, you are nearly " . $age + 1;
 }
 This is OK
 hello("Simon", "42");
  • 14. Strict typing Unless you enable strict mode
 declare(strict_types=1);
 function hello (string $name, int $age) { 
 echo "Hello $name, you are nearly " . $age + 1;
 } This throws a Fatal error exception
 hello("Simon", "42");
  • 15. Type hinting.. PHP 5.0 Class Name
 self PHP 5.1 array PHP 5.4 callable PHP 7.0 bool float int string PHP 7.1 iterable (array or Traversable)
 Nullable types, e.g. ?string void return type
  • 16. Migration • Upgrade to PHP5.6 • Then PHP7 • Migration guides:
 http://php.net/manual/en/migration56.php
 http://php.net/manual/en/migration70.php
 http://php.net/manual/en/migration71.php