SlideShare a Scribd company logo
What’s New in PHP 7.0
A the only reason why it’s worth upgrading
Andrea Telatin

BMR Genomics srl
Overview 

and why to switch
About this release
• Released on December 3, 2015

• Major release after 11 years
• Two years in development
• New Zend Engine
What happened to 6.0?
• Had the goal to support Unicode everywhere
• Too ambitious?

Goal dropped, yet after 5 years of conferences,
blogs, …
• Features of “6.0” entered in the 5.x
• namespaces, closures, short array syntax…
Performance
PHP 7.0 has significantly better performance
• Probably the only reason to upgrade.
• Optimized parsing, and lower memory ~2X faster
• Compares with HHVM (FaceBook)
• http://www.zend.com/en/resources/php7_infographic
PHP 7.0 new features (and new interpreter)
PHP 7.0 new features (and new interpreter)
PHP 7.0 new features (and new interpreter)
New Features
Type hinting
• Specify the type of function arguments
• Can be done in three ways: none, coercitive, strict
• Types available: int, string, bool, array, float
• I think will be super cool for IDEs,…
Type hinting
• Specify the type of function arguments
• Can be done in three ways: none, coercitive or strict

function SumNumbers($first, $second) {
echo $first . " (". gettype($first) . " + n";
echo $second ." (". gettype($second). " = n";
$result = $first + $second;
echo $result ." (". gettype($result).")n";
}
Type hinting
SumNumbers(1, 5); 

SumNumbers(1.0, 5.0); // What happens?
SumNumbers(“1”, “5”); // What happens?
• Coercitive declaration:
function SumNumbers(int $first,int $second) { …

// PHP immediately convert input into integers
• Strict declaration:
declare(strict_type=1);

function SumNumbers(int $first,int $second) { …

// error if we don’t pass integer (type error)
Return type declaration
• Specify the type of what we return from functions
• Again can be done in three ways: 

none, coercitive, strict
• Again types available: int, string, bool, array, float
Return type declaration
• Coercive (convert the result if needed)

function SumNumbers($first, $second): int {
$result = $first + $second;

return $result;
}
• Strict (return error if the type doesn’t match)

declare(strict_types = 1);

function SumNumbers($first, $second): int {
return $first + $second;

}
New function intdiv()
• Yes, its for integer division

echo intdiv(4, 3);

// Always return an int. 

// More precision avoiding float! 

// compare with floor($bignum/2);
• Completes the modulus operator
Uniform variable syntax
• When we used variable variable-names:

$var_name = 'FirstName';
$FirstName = 'Andrea';
$Person = ('Name' => 'Andrea', 'Surname' => 'Telatin');
echo $$var_name; // prints Andrea
echo $$Person['Name']; // Illegal in PHP5, valid in 7
• Can be used for nested variables
Unicode
• A codepoint represents a character/symbol/emoji
• Encoded as hex number, eg 2603 is
• In PHP is like print "Hello from u{2603}"
• u{1F600} = 😀
Catch exceptions: PHP 5
function getGeneCoord($ensembleID) {
if (isnull($ensembleID) {
throw new Exception('No ID provided');
}
return $ensembleID->cordinates;
}
try {
print getGeneCoord($id)."n";
} catch (Exception $e) {
echo "Raised exception: $en";
}
Catch exceptions: PHP 7
function getGeneCoord($ensembleID) {
if (isnull($ensembleID) {
throw new Exception('No ID provided');
}
return $ensembleID->cordinates;
}
try {
print getGeneCoord($id)."n";
} catch (Error $e) {
echo "Raised exception: $en";
}
Other new features
• Anonymous classes in OOP: quick, one-time use
classes (omit class name)

$instance = new class { … }
• Null coalescent operator: ??

Return the first not-null value in a series

$username = $db[name] ?? $default;
• Spaceship operator: <=>

// -1 if <, 0 if ==, 1 if >… Useful in switch
and more!
Deprecated things
PHP 4 constructors
• Class with a method with the same name as the
class. Called during creation.
• Since PHP 5 the common practice is calling the
method _constructor()
Deleted things
Alternative PHP marks
• The standard tags are

<?php code here ?>
• Deleted alternatives:

<% ASP style %>

<%= ASP style with echo %> 



<script language="php">

html style 

</script>

• Short open tags still OK but will they for long? <?= … ?>
Other deletions
• ereg_ functions to preg_ functions
• mysql_ functions to mysqli_ functions
• mcrypt_generic_end, mcrypt_cbc……..
Timezone warnings
• PHP5 fired a warning if you didn’t set
date.timezone in PHP.ini file (default was UTC)
• Default is still UTC, but warning removed
PHP 7.0 new features (and new interpreter)
Ad

More Related Content

What's hot (20)

Slide
SlideSlide
Slide
Naing Lin Aung
 
JavaScript: The Language
JavaScript: The LanguageJavaScript: The Language
JavaScript: The Language
Engage Software
 
The promise of asynchronous PHP
The promise of asynchronous PHPThe promise of asynchronous PHP
The promise of asynchronous PHP
Wim Godden
 
Functions in php
Functions in phpFunctions in php
Functions in php
Mudasir Syed
 
PHP Unit 3 functions_in_php_2
PHP Unit 3 functions_in_php_2PHP Unit 3 functions_in_php_2
PHP Unit 3 functions_in_php_2
Kumar
 
Typed Properties and more: What's coming in PHP 7.4?
Typed Properties and more: What's coming in PHP 7.4?Typed Properties and more: What's coming in PHP 7.4?
Typed Properties and more: What's coming in PHP 7.4?
Nikita Popov
 
Data Types In PHP
Data Types In PHPData Types In PHP
Data Types In PHP
Mark Niebergall
 
PHP - DataType,Variable,Constant,Operators,Array,Include and require
PHP - DataType,Variable,Constant,Operators,Array,Include and requirePHP - DataType,Variable,Constant,Operators,Array,Include and require
PHP - DataType,Variable,Constant,Operators,Array,Include and require
TheCreativedev Blog
 
PHP function
PHP functionPHP function
PHP function
monikadeshmane
 
Object-Oriented Programming with PHP (part 1)
Object-Oriented Programming with PHP (part 1)Object-Oriented Programming with PHP (part 1)
Object-Oriented Programming with PHP (part 1)
Bozhidar Boshnakov
 
PHP Enums - PHPCon Japan 2021
PHP Enums - PHPCon Japan 2021PHP Enums - PHPCon Japan 2021
PHP Enums - PHPCon Japan 2021
Ayesh Karunaratne
 
PHP Basics
PHP BasicsPHP Basics
PHP Basics
Henry Osborne
 
Functions in PHP
Functions in PHPFunctions in PHP
Functions in PHP
Vineet Kumar Saini
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
Jussi Pohjolainen
 
Operators in PHP
Operators in PHPOperators in PHP
Operators in PHP
Vineet Kumar Saini
 
Intermediate PHP
Intermediate PHPIntermediate PHP
Intermediate PHP
Bradley Holt
 
Php Tutorials for Beginners
Php Tutorials for BeginnersPhp Tutorials for Beginners
Php Tutorials for Beginners
Vineet Kumar Saini
 
Python decorators
Python decoratorsPython decorators
Python decorators
Guillermo Blasco Jiménez
 
Python master class part 1
Python master class part 1Python master class part 1
Python master class part 1
Chathuranga Bandara
 
PHP7. Game Changer.
PHP7. Game Changer. PHP7. Game Changer.
PHP7. Game Changer.
Haim Michael
 
JavaScript: The Language
JavaScript: The LanguageJavaScript: The Language
JavaScript: The Language
Engage Software
 
The promise of asynchronous PHP
The promise of asynchronous PHPThe promise of asynchronous PHP
The promise of asynchronous PHP
Wim Godden
 
PHP Unit 3 functions_in_php_2
PHP Unit 3 functions_in_php_2PHP Unit 3 functions_in_php_2
PHP Unit 3 functions_in_php_2
Kumar
 
Typed Properties and more: What's coming in PHP 7.4?
Typed Properties and more: What's coming in PHP 7.4?Typed Properties and more: What's coming in PHP 7.4?
Typed Properties and more: What's coming in PHP 7.4?
Nikita Popov
 
PHP - DataType,Variable,Constant,Operators,Array,Include and require
PHP - DataType,Variable,Constant,Operators,Array,Include and requirePHP - DataType,Variable,Constant,Operators,Array,Include and require
PHP - DataType,Variable,Constant,Operators,Array,Include and require
TheCreativedev Blog
 
Object-Oriented Programming with PHP (part 1)
Object-Oriented Programming with PHP (part 1)Object-Oriented Programming with PHP (part 1)
Object-Oriented Programming with PHP (part 1)
Bozhidar Boshnakov
 
PHP Enums - PHPCon Japan 2021
PHP Enums - PHPCon Japan 2021PHP Enums - PHPCon Japan 2021
PHP Enums - PHPCon Japan 2021
Ayesh Karunaratne
 
PHP7. Game Changer.
PHP7. Game Changer. PHP7. Game Changer.
PHP7. Game Changer.
Haim Michael
 

Similar to PHP 7.0 new features (and new interpreter) (20)

PHP 8: Process & Fixing Insanity
PHP 8: Process & Fixing InsanityPHP 8: Process & Fixing Insanity
PHP 8: Process & Fixing Insanity
GeorgePeterBanyard
 
What's new in PHP 8.0?
What's new in PHP 8.0?What's new in PHP 8.0?
What's new in PHP 8.0?
Nikita Popov
 
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
 
Preparing for the next PHP version (5.6)
Preparing for the next PHP version (5.6)Preparing for the next PHP version (5.6)
Preparing for the next PHP version (5.6)
Damien Seguy
 
PHP7 is coming
PHP7 is comingPHP7 is coming
PHP7 is coming
julien pauli
 
PHP7: Hello World!
PHP7: Hello World!PHP7: Hello World!
PHP7: Hello World!
Pavel Nikolov
 
PHP7 Presentation
PHP7 PresentationPHP7 Presentation
PHP7 Presentation
David Sanchez
 
Object Oriented PHP - PART-2
Object Oriented PHP - PART-2Object Oriented PHP - PART-2
Object Oriented PHP - PART-2
Jalpesh Vasa
 
Giới thiệu PHP 7
Giới thiệu PHP 7Giới thiệu PHP 7
Giới thiệu PHP 7
ZendVN
 
Introduction to php basics
Introduction to php   basicsIntroduction to php   basics
Introduction to php basics
baabtra.com - No. 1 supplier of quality freshers
 
What's new in PHP 7.1
What's new in PHP 7.1What's new in PHP 7.1
What's new in PHP 7.1
Simon Jones
 
OOP
OOPOOP
OOP
thinkphp
 
C Tutorials
C TutorialsC Tutorials
C Tutorials
Sudharsan S
 
Zend Certification PHP 5 Sample Questions
Zend Certification PHP 5 Sample QuestionsZend Certification PHP 5 Sample Questions
Zend Certification PHP 5 Sample Questions
Jagat Kothari
 
جلسه پنجم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲- ارائه ۱
جلسه پنجم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲- ارائه ۱جلسه پنجم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲- ارائه ۱
جلسه پنجم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲- ارائه ۱
Mohammad Reza Kamalifard
 
Pythonlearn-04-Functions (1).pptx
Pythonlearn-04-Functions (1).pptxPythonlearn-04-Functions (1).pptx
Pythonlearn-04-Functions (1).pptx
leavatin
 
What's new in PHP 8.0?
What's new in PHP 8.0?What's new in PHP 8.0?
What's new in PHP 8.0?
Nikita Popov
 
Python Learn Function with example programs
Python Learn Function with example programsPython Learn Function with example programs
Python Learn Function with example programs
GeethaPanneer
 
Drupaljam xl 2019 presentation multilingualism makes better programmers
Drupaljam xl 2019 presentation   multilingualism makes better programmersDrupaljam xl 2019 presentation   multilingualism makes better programmers
Drupaljam xl 2019 presentation multilingualism makes better programmers
Alexander Varwijk
 
New in php 7
New in php 7New in php 7
New in php 7
Vic Metcalfe
 
PHP 8: Process & Fixing Insanity
PHP 8: Process & Fixing InsanityPHP 8: Process & Fixing Insanity
PHP 8: Process & Fixing Insanity
GeorgePeterBanyard
 
What's new in PHP 8.0?
What's new in PHP 8.0?What's new in PHP 8.0?
What's new in PHP 8.0?
Nikita Popov
 
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
 
Preparing for the next PHP version (5.6)
Preparing for the next PHP version (5.6)Preparing for the next PHP version (5.6)
Preparing for the next PHP version (5.6)
Damien Seguy
 
Object Oriented PHP - PART-2
Object Oriented PHP - PART-2Object Oriented PHP - PART-2
Object Oriented PHP - PART-2
Jalpesh Vasa
 
Giới thiệu PHP 7
Giới thiệu PHP 7Giới thiệu PHP 7
Giới thiệu PHP 7
ZendVN
 
What's new in PHP 7.1
What's new in PHP 7.1What's new in PHP 7.1
What's new in PHP 7.1
Simon Jones
 
Zend Certification PHP 5 Sample Questions
Zend Certification PHP 5 Sample QuestionsZend Certification PHP 5 Sample Questions
Zend Certification PHP 5 Sample Questions
Jagat Kothari
 
جلسه پنجم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲- ارائه ۱
جلسه پنجم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲- ارائه ۱جلسه پنجم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲- ارائه ۱
جلسه پنجم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲- ارائه ۱
Mohammad Reza Kamalifard
 
Pythonlearn-04-Functions (1).pptx
Pythonlearn-04-Functions (1).pptxPythonlearn-04-Functions (1).pptx
Pythonlearn-04-Functions (1).pptx
leavatin
 
What's new in PHP 8.0?
What's new in PHP 8.0?What's new in PHP 8.0?
What's new in PHP 8.0?
Nikita Popov
 
Python Learn Function with example programs
Python Learn Function with example programsPython Learn Function with example programs
Python Learn Function with example programs
GeethaPanneer
 
Drupaljam xl 2019 presentation multilingualism makes better programmers
Drupaljam xl 2019 presentation   multilingualism makes better programmersDrupaljam xl 2019 presentation   multilingualism makes better programmers
Drupaljam xl 2019 presentation multilingualism makes better programmers
Alexander Varwijk
 
Ad

More from Andrea Telatin (13)

Next Generation Sequencing revolution (February 2010 - PhD retreat)
Next Generation Sequencing revolution (February 2010 - PhD retreat)Next Generation Sequencing revolution (February 2010 - PhD retreat)
Next Generation Sequencing revolution (February 2010 - PhD retreat)
Andrea Telatin
 
A primer on microbial diversity: 16S Amplicons analysis
A primer on microbial diversity: 16S Amplicons analysisA primer on microbial diversity: 16S Amplicons analysis
A primer on microbial diversity: 16S Amplicons analysis
Andrea Telatin
 
Flash introduction to Qiime2 -- 16S Amplicon analysis
Flash introduction to Qiime2 -- 16S Amplicon analysisFlash introduction to Qiime2 -- 16S Amplicon analysis
Flash introduction to Qiime2 -- 16S Amplicon analysis
Andrea Telatin
 
First adventure within a shell - Andrea Telatin at Quadram Institute
First adventure within a shell - Andrea Telatin at Quadram InstituteFirst adventure within a shell - Andrea Telatin at Quadram Institute
First adventure within a shell - Andrea Telatin at Quadram Institute
Andrea Telatin
 
Sequenziamento ed assemblaggio di genomi batterici
Sequenziamento ed assemblaggio di genomi battericiSequenziamento ed assemblaggio di genomi batterici
Sequenziamento ed assemblaggio di genomi batterici
Andrea Telatin
 
Laboratorio di Biologia Molecolare I - UniPD - 2010
Laboratorio di Biologia Molecolare I - UniPD - 2010Laboratorio di Biologia Molecolare I - UniPD - 2010
Laboratorio di Biologia Molecolare I - UniPD - 2010
Andrea Telatin
 
Uno sguardo al microbioma degli Italiani
Uno sguardo al microbioma degli ItalianiUno sguardo al microbioma degli Italiani
Uno sguardo al microbioma degli Italiani
Andrea Telatin
 
Target Enrichment with NGS: Cardiomyopathy as a case study - BMR Genomics
Target Enrichment with NGS: Cardiomyopathy as a case study - BMR GenomicsTarget Enrichment with NGS: Cardiomyopathy as a case study - BMR Genomics
Target Enrichment with NGS: Cardiomyopathy as a case study - BMR Genomics
Andrea Telatin
 
Bioinformatica: Esercizi su Perl, espressioni regolari e altre amenità (BMR G...
Bioinformatica: Esercizi su Perl, espressioni regolari e altre amenità (BMR G...Bioinformatica: Esercizi su Perl, espressioni regolari e altre amenità (BMR G...
Bioinformatica: Esercizi su Perl, espressioni regolari e altre amenità (BMR G...
Andrea Telatin
 
Bioinformatica: Leggere file con Perl, e introduzione alle espressioni regola...
Bioinformatica: Leggere file con Perl, e introduzione alle espressioni regola...Bioinformatica: Leggere file con Perl, e introduzione alle espressioni regola...
Bioinformatica: Leggere file con Perl, e introduzione alle espressioni regola...
Andrea Telatin
 
Bioinformatica: introduzione (BMR Genomics) - Lezione 25 luglio 2014
Bioinformatica: introduzione (BMR Genomics) - Lezione 25 luglio 2014Bioinformatica: introduzione (BMR Genomics) - Lezione 25 luglio 2014
Bioinformatica: introduzione (BMR Genomics) - Lezione 25 luglio 2014
Andrea Telatin
 
Introduzione al Perl (BMR Genomics) - Lezione 1 Agosto 2014
Introduzione al Perl (BMR Genomics) - Lezione 1 Agosto 2014Introduzione al Perl (BMR Genomics) - Lezione 1 Agosto 2014
Introduzione al Perl (BMR Genomics) - Lezione 1 Agosto 2014
Andrea Telatin
 
Introduction to 16S Analysis with NGS - BMR Genomics
Introduction to 16S Analysis with NGS - BMR GenomicsIntroduction to 16S Analysis with NGS - BMR Genomics
Introduction to 16S Analysis with NGS - BMR Genomics
Andrea Telatin
 
Next Generation Sequencing revolution (February 2010 - PhD retreat)
Next Generation Sequencing revolution (February 2010 - PhD retreat)Next Generation Sequencing revolution (February 2010 - PhD retreat)
Next Generation Sequencing revolution (February 2010 - PhD retreat)
Andrea Telatin
 
A primer on microbial diversity: 16S Amplicons analysis
A primer on microbial diversity: 16S Amplicons analysisA primer on microbial diversity: 16S Amplicons analysis
A primer on microbial diversity: 16S Amplicons analysis
Andrea Telatin
 
Flash introduction to Qiime2 -- 16S Amplicon analysis
Flash introduction to Qiime2 -- 16S Amplicon analysisFlash introduction to Qiime2 -- 16S Amplicon analysis
Flash introduction to Qiime2 -- 16S Amplicon analysis
Andrea Telatin
 
First adventure within a shell - Andrea Telatin at Quadram Institute
First adventure within a shell - Andrea Telatin at Quadram InstituteFirst adventure within a shell - Andrea Telatin at Quadram Institute
First adventure within a shell - Andrea Telatin at Quadram Institute
Andrea Telatin
 
Sequenziamento ed assemblaggio di genomi batterici
Sequenziamento ed assemblaggio di genomi battericiSequenziamento ed assemblaggio di genomi batterici
Sequenziamento ed assemblaggio di genomi batterici
Andrea Telatin
 
Laboratorio di Biologia Molecolare I - UniPD - 2010
Laboratorio di Biologia Molecolare I - UniPD - 2010Laboratorio di Biologia Molecolare I - UniPD - 2010
Laboratorio di Biologia Molecolare I - UniPD - 2010
Andrea Telatin
 
Uno sguardo al microbioma degli Italiani
Uno sguardo al microbioma degli ItalianiUno sguardo al microbioma degli Italiani
Uno sguardo al microbioma degli Italiani
Andrea Telatin
 
Target Enrichment with NGS: Cardiomyopathy as a case study - BMR Genomics
Target Enrichment with NGS: Cardiomyopathy as a case study - BMR GenomicsTarget Enrichment with NGS: Cardiomyopathy as a case study - BMR Genomics
Target Enrichment with NGS: Cardiomyopathy as a case study - BMR Genomics
Andrea Telatin
 
Bioinformatica: Esercizi su Perl, espressioni regolari e altre amenità (BMR G...
Bioinformatica: Esercizi su Perl, espressioni regolari e altre amenità (BMR G...Bioinformatica: Esercizi su Perl, espressioni regolari e altre amenità (BMR G...
Bioinformatica: Esercizi su Perl, espressioni regolari e altre amenità (BMR G...
Andrea Telatin
 
Bioinformatica: Leggere file con Perl, e introduzione alle espressioni regola...
Bioinformatica: Leggere file con Perl, e introduzione alle espressioni regola...Bioinformatica: Leggere file con Perl, e introduzione alle espressioni regola...
Bioinformatica: Leggere file con Perl, e introduzione alle espressioni regola...
Andrea Telatin
 
Bioinformatica: introduzione (BMR Genomics) - Lezione 25 luglio 2014
Bioinformatica: introduzione (BMR Genomics) - Lezione 25 luglio 2014Bioinformatica: introduzione (BMR Genomics) - Lezione 25 luglio 2014
Bioinformatica: introduzione (BMR Genomics) - Lezione 25 luglio 2014
Andrea Telatin
 
Introduzione al Perl (BMR Genomics) - Lezione 1 Agosto 2014
Introduzione al Perl (BMR Genomics) - Lezione 1 Agosto 2014Introduzione al Perl (BMR Genomics) - Lezione 1 Agosto 2014
Introduzione al Perl (BMR Genomics) - Lezione 1 Agosto 2014
Andrea Telatin
 
Introduction to 16S Analysis with NGS - BMR Genomics
Introduction to 16S Analysis with NGS - BMR GenomicsIntroduction to 16S Analysis with NGS - BMR Genomics
Introduction to 16S Analysis with NGS - BMR Genomics
Andrea Telatin
 
Ad

Recently uploaded (20)

Artificial Intelligence (AI) basics.pptx
Artificial Intelligence (AI) basics.pptxArtificial Intelligence (AI) basics.pptx
Artificial Intelligence (AI) basics.pptx
aditichinar
 
Resistance measurement and cfd test on darpa subboff model
Resistance measurement and cfd test on darpa subboff modelResistance measurement and cfd test on darpa subboff model
Resistance measurement and cfd test on darpa subboff model
INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR
 
Value Stream Mapping Worskshops for Intelligent Continuous Security
Value Stream Mapping Worskshops for Intelligent Continuous SecurityValue Stream Mapping Worskshops for Intelligent Continuous Security
Value Stream Mapping Worskshops for Intelligent Continuous Security
Marc Hornbeek
 
Smart_Storage_Systems_Production_Engineering.pptx
Smart_Storage_Systems_Production_Engineering.pptxSmart_Storage_Systems_Production_Engineering.pptx
Smart_Storage_Systems_Production_Engineering.pptx
rushikeshnavghare94
 
RICS Membership-(The Royal Institution of Chartered Surveyors).pdf
RICS Membership-(The Royal Institution of Chartered Surveyors).pdfRICS Membership-(The Royal Institution of Chartered Surveyors).pdf
RICS Membership-(The Royal Institution of Chartered Surveyors).pdf
MohamedAbdelkader115
 
Main cotrol jdbjbdcnxbjbjzjjjcjicbjxbcjcxbjcxb
Main cotrol jdbjbdcnxbjbjzjjjcjicbjxbcjcxbjcxbMain cotrol jdbjbdcnxbjbjzjjjcjicbjxbcjcxbjcxb
Main cotrol jdbjbdcnxbjbjzjjjcjicbjxbcjcxbjcxb
SunilSingh610661
 
lecture5.pptxJHKGJFHDGTFGYIUOIUIPIOIPUOHIYGUYFGIH
lecture5.pptxJHKGJFHDGTFGYIUOIUIPIOIPUOHIYGUYFGIHlecture5.pptxJHKGJFHDGTFGYIUOIUIPIOIPUOHIYGUYFGIH
lecture5.pptxJHKGJFHDGTFGYIUOIUIPIOIPUOHIYGUYFGIH
Abodahab
 
Artificial Intelligence introduction.pptx
Artificial Intelligence introduction.pptxArtificial Intelligence introduction.pptx
Artificial Intelligence introduction.pptx
DrMarwaElsherif
 
Oil-gas_Unconventional oil and gass_reseviours.pdf
Oil-gas_Unconventional oil and gass_reseviours.pdfOil-gas_Unconventional oil and gass_reseviours.pdf
Oil-gas_Unconventional oil and gass_reseviours.pdf
M7md3li2
 
Degree_of_Automation.pdf for Instrumentation and industrial specialist
Degree_of_Automation.pdf for  Instrumentation  and industrial specialistDegree_of_Automation.pdf for  Instrumentation  and industrial specialist
Degree_of_Automation.pdf for Instrumentation and industrial specialist
shreyabhosale19
 
Introduction to FLUID MECHANICS & KINEMATICS
Introduction to FLUID MECHANICS &  KINEMATICSIntroduction to FLUID MECHANICS &  KINEMATICS
Introduction to FLUID MECHANICS & KINEMATICS
narayanaswamygdas
 
DATA-DRIVEN SHOULDER INVERSE KINEMATICS YoungBeom Kim1 , Byung-Ha Park1 , Kwa...
DATA-DRIVEN SHOULDER INVERSE KINEMATICS YoungBeom Kim1 , Byung-Ha Park1 , Kwa...DATA-DRIVEN SHOULDER INVERSE KINEMATICS YoungBeom Kim1 , Byung-Ha Park1 , Kwa...
DATA-DRIVEN SHOULDER INVERSE KINEMATICS YoungBeom Kim1 , Byung-Ha Park1 , Kwa...
charlesdick1345
 
introduction to machine learining for beginers
introduction to machine learining for beginersintroduction to machine learining for beginers
introduction to machine learining for beginers
JoydebSheet
 
some basics electrical and electronics knowledge
some basics electrical and electronics knowledgesome basics electrical and electronics knowledge
some basics electrical and electronics knowledge
nguyentrungdo88
 
Data Structures_Linear data structures Linked Lists.pptx
Data Structures_Linear data structures Linked Lists.pptxData Structures_Linear data structures Linked Lists.pptx
Data Structures_Linear data structures Linked Lists.pptx
RushaliDeshmukh2
 
DSP and MV the Color image processing.ppt
DSP and MV the  Color image processing.pptDSP and MV the  Color image processing.ppt
DSP and MV the Color image processing.ppt
HafizAhamed8
 
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptxExplainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
MahaveerVPandit
 
theory-slides-for react for beginners.pptx
theory-slides-for react for beginners.pptxtheory-slides-for react for beginners.pptx
theory-slides-for react for beginners.pptx
sanchezvanessa7896
 
Machine learning project on employee attrition detection using (2).pptx
Machine learning project on employee attrition detection using (2).pptxMachine learning project on employee attrition detection using (2).pptx
Machine learning project on employee attrition detection using (2).pptx
rajeswari89780
 
Process Parameter Optimization for Minimizing Springback in Cold Drawing Proc...
Process Parameter Optimization for Minimizing Springback in Cold Drawing Proc...Process Parameter Optimization for Minimizing Springback in Cold Drawing Proc...
Process Parameter Optimization for Minimizing Springback in Cold Drawing Proc...
Journal of Soft Computing in Civil Engineering
 
Artificial Intelligence (AI) basics.pptx
Artificial Intelligence (AI) basics.pptxArtificial Intelligence (AI) basics.pptx
Artificial Intelligence (AI) basics.pptx
aditichinar
 
Value Stream Mapping Worskshops for Intelligent Continuous Security
Value Stream Mapping Worskshops for Intelligent Continuous SecurityValue Stream Mapping Worskshops for Intelligent Continuous Security
Value Stream Mapping Worskshops for Intelligent Continuous Security
Marc Hornbeek
 
Smart_Storage_Systems_Production_Engineering.pptx
Smart_Storage_Systems_Production_Engineering.pptxSmart_Storage_Systems_Production_Engineering.pptx
Smart_Storage_Systems_Production_Engineering.pptx
rushikeshnavghare94
 
RICS Membership-(The Royal Institution of Chartered Surveyors).pdf
RICS Membership-(The Royal Institution of Chartered Surveyors).pdfRICS Membership-(The Royal Institution of Chartered Surveyors).pdf
RICS Membership-(The Royal Institution of Chartered Surveyors).pdf
MohamedAbdelkader115
 
Main cotrol jdbjbdcnxbjbjzjjjcjicbjxbcjcxbjcxb
Main cotrol jdbjbdcnxbjbjzjjjcjicbjxbcjcxbjcxbMain cotrol jdbjbdcnxbjbjzjjjcjicbjxbcjcxbjcxb
Main cotrol jdbjbdcnxbjbjzjjjcjicbjxbcjcxbjcxb
SunilSingh610661
 
lecture5.pptxJHKGJFHDGTFGYIUOIUIPIOIPUOHIYGUYFGIH
lecture5.pptxJHKGJFHDGTFGYIUOIUIPIOIPUOHIYGUYFGIHlecture5.pptxJHKGJFHDGTFGYIUOIUIPIOIPUOHIYGUYFGIH
lecture5.pptxJHKGJFHDGTFGYIUOIUIPIOIPUOHIYGUYFGIH
Abodahab
 
Artificial Intelligence introduction.pptx
Artificial Intelligence introduction.pptxArtificial Intelligence introduction.pptx
Artificial Intelligence introduction.pptx
DrMarwaElsherif
 
Oil-gas_Unconventional oil and gass_reseviours.pdf
Oil-gas_Unconventional oil and gass_reseviours.pdfOil-gas_Unconventional oil and gass_reseviours.pdf
Oil-gas_Unconventional oil and gass_reseviours.pdf
M7md3li2
 
Degree_of_Automation.pdf for Instrumentation and industrial specialist
Degree_of_Automation.pdf for  Instrumentation  and industrial specialistDegree_of_Automation.pdf for  Instrumentation  and industrial specialist
Degree_of_Automation.pdf for Instrumentation and industrial specialist
shreyabhosale19
 
Introduction to FLUID MECHANICS & KINEMATICS
Introduction to FLUID MECHANICS &  KINEMATICSIntroduction to FLUID MECHANICS &  KINEMATICS
Introduction to FLUID MECHANICS & KINEMATICS
narayanaswamygdas
 
DATA-DRIVEN SHOULDER INVERSE KINEMATICS YoungBeom Kim1 , Byung-Ha Park1 , Kwa...
DATA-DRIVEN SHOULDER INVERSE KINEMATICS YoungBeom Kim1 , Byung-Ha Park1 , Kwa...DATA-DRIVEN SHOULDER INVERSE KINEMATICS YoungBeom Kim1 , Byung-Ha Park1 , Kwa...
DATA-DRIVEN SHOULDER INVERSE KINEMATICS YoungBeom Kim1 , Byung-Ha Park1 , Kwa...
charlesdick1345
 
introduction to machine learining for beginers
introduction to machine learining for beginersintroduction to machine learining for beginers
introduction to machine learining for beginers
JoydebSheet
 
some basics electrical and electronics knowledge
some basics electrical and electronics knowledgesome basics electrical and electronics knowledge
some basics electrical and electronics knowledge
nguyentrungdo88
 
Data Structures_Linear data structures Linked Lists.pptx
Data Structures_Linear data structures Linked Lists.pptxData Structures_Linear data structures Linked Lists.pptx
Data Structures_Linear data structures Linked Lists.pptx
RushaliDeshmukh2
 
DSP and MV the Color image processing.ppt
DSP and MV the  Color image processing.pptDSP and MV the  Color image processing.ppt
DSP and MV the Color image processing.ppt
HafizAhamed8
 
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptxExplainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
MahaveerVPandit
 
theory-slides-for react for beginners.pptx
theory-slides-for react for beginners.pptxtheory-slides-for react for beginners.pptx
theory-slides-for react for beginners.pptx
sanchezvanessa7896
 
Machine learning project on employee attrition detection using (2).pptx
Machine learning project on employee attrition detection using (2).pptxMachine learning project on employee attrition detection using (2).pptx
Machine learning project on employee attrition detection using (2).pptx
rajeswari89780
 

PHP 7.0 new features (and new interpreter)

  • 1. What’s New in PHP 7.0 A the only reason why it’s worth upgrading Andrea Telatin
 BMR Genomics srl
  • 3. About this release • Released on December 3, 2015 • Major release after 11 years • Two years in development • New Zend Engine
  • 4. What happened to 6.0? • Had the goal to support Unicode everywhere • Too ambitious?
 Goal dropped, yet after 5 years of conferences, blogs, … • Features of “6.0” entered in the 5.x • namespaces, closures, short array syntax…
  • 5. Performance PHP 7.0 has significantly better performance • Probably the only reason to upgrade. • Optimized parsing, and lower memory ~2X faster • Compares with HHVM (FaceBook) • http://www.zend.com/en/resources/php7_infographic
  • 10. Type hinting • Specify the type of function arguments • Can be done in three ways: none, coercitive, strict • Types available: int, string, bool, array, float • I think will be super cool for IDEs,…
  • 11. Type hinting • Specify the type of function arguments • Can be done in three ways: none, coercitive or strict
 function SumNumbers($first, $second) { echo $first . " (". gettype($first) . " + n"; echo $second ." (". gettype($second). " = n"; $result = $first + $second; echo $result ." (". gettype($result).")n"; }
  • 12. Type hinting SumNumbers(1, 5); 
 SumNumbers(1.0, 5.0); // What happens? SumNumbers(“1”, “5”); // What happens? • Coercitive declaration: function SumNumbers(int $first,int $second) { …
 // PHP immediately convert input into integers • Strict declaration: declare(strict_type=1);
 function SumNumbers(int $first,int $second) { …
 // error if we don’t pass integer (type error)
  • 13. Return type declaration • Specify the type of what we return from functions • Again can be done in three ways: 
 none, coercitive, strict • Again types available: int, string, bool, array, float
  • 14. Return type declaration • Coercive (convert the result if needed)
 function SumNumbers($first, $second): int { $result = $first + $second;
 return $result; } • Strict (return error if the type doesn’t match)
 declare(strict_types = 1);
 function SumNumbers($first, $second): int { return $first + $second;
 }
  • 15. New function intdiv() • Yes, its for integer division
 echo intdiv(4, 3);
 // Always return an int. 
 // More precision avoiding float! 
 // compare with floor($bignum/2); • Completes the modulus operator
  • 16. Uniform variable syntax • When we used variable variable-names:
 $var_name = 'FirstName'; $FirstName = 'Andrea'; $Person = ('Name' => 'Andrea', 'Surname' => 'Telatin'); echo $$var_name; // prints Andrea echo $$Person['Name']; // Illegal in PHP5, valid in 7 • Can be used for nested variables
  • 17. Unicode • A codepoint represents a character/symbol/emoji • Encoded as hex number, eg 2603 is • In PHP is like print "Hello from u{2603}" • u{1F600} = 😀
  • 18. Catch exceptions: PHP 5 function getGeneCoord($ensembleID) { if (isnull($ensembleID) { throw new Exception('No ID provided'); } return $ensembleID->cordinates; } try { print getGeneCoord($id)."n"; } catch (Exception $e) { echo "Raised exception: $en"; }
  • 19. Catch exceptions: PHP 7 function getGeneCoord($ensembleID) { if (isnull($ensembleID) { throw new Exception('No ID provided'); } return $ensembleID->cordinates; } try { print getGeneCoord($id)."n"; } catch (Error $e) { echo "Raised exception: $en"; }
  • 20. Other new features • Anonymous classes in OOP: quick, one-time use classes (omit class name)
 $instance = new class { … } • Null coalescent operator: ??
 Return the first not-null value in a series
 $username = $db[name] ?? $default; • Spaceship operator: <=>
 // -1 if <, 0 if ==, 1 if >… Useful in switch and more!
  • 22. PHP 4 constructors • Class with a method with the same name as the class. Called during creation. • Since PHP 5 the common practice is calling the method _constructor()
  • 24. Alternative PHP marks • The standard tags are
 <?php code here ?> • Deleted alternatives:
 <% ASP style %>
 <%= ASP style with echo %> 
 
 <script language="php">
 html style 
 </script>
 • Short open tags still OK but will they for long? <?= … ?>
  • 25. Other deletions • ereg_ functions to preg_ functions • mysql_ functions to mysqli_ functions • mcrypt_generic_end, mcrypt_cbc……..
  • 26. Timezone warnings • PHP5 fired a warning if you didn’t set date.timezone in PHP.ini file (default was UTC) • Default is still UTC, but warning removed