SlideShare ist ein Scribd-Unternehmen logo
1 von 23
PHP 7
What’s new in PHP 7
By: Joshua Copeland
Joshua Copeland
 PHP lover for 7+ years
 Lead Developer at The Selling Source (we need a DBA)
 Father, husband, and overall awesome guy
 Software Developer for over 10 years
 First human to be a computer
 My Twitter Handle : @PsyCodeDotOrg
Proposed Milestones
 1. Line up any remaining RFCs that target PHP 7.0.
 2. Finalize implementation & testing of new features.
Mar 16 - Jun 15 (3 months)
 3. Release Candidate (RC) cycles
Jun 16 - Oct 15 (3 months)
 4. GA/Release
Mid October 2015
 https://wiki.php.net/rfc/php7timeline
Inconsistency Fixes
 Abstract Syntax Tree (AST)
 Decoupled the parser from the compiler.
 list() currently assigns variables right-to-left, the AST implementation
will assign them left-to-right instead.
 Auto-vivification order for by-reference assignments.
 10-15% faster compile times, but requires more memory.
 Directly calling __clone is allowed
https://wiki.php.net/rfc/abstract_syntax_tree
Uniform Variable Syntax
 Introduction of an internally consistent and complete variable
syntax. To achieve this goal the semantics of some rarely used
variable-variable constructions need to be changed.
 Call closures assigned to properties using ($object->closureProperty)()
 Chain static calls. Ex: $foo::$bar::$bat
 Semantics when using variable-variables/properties
 https://wiki.php.net/rfc/uniform_variable_syntax
Biggest reason to update
Biggest reason to update
Performance!
PHP 7 is on par with HHVM
Memory Savings
Backwards Incompatible Changes
 Call to member function on a non-object now catchable fatal error.
https://wiki.php.net/rfc/catchable-call-to-member-of-non-object
 ASP and script tags have been removed
Ex. <% <%= <script language=“php”></script>
 Removal of all deprecated functionality.
https://wiki.php.net/rfc/remove_deprecated_functionality_in_php7
 Removal of the POSIX compatible regular expressions extension, ext/ereg
(deprecated in 5.3) and the old ext/mysql extension (deprecated in 5.5).
 Switch statements throw and error when more than one default case found.
New Features
 Scalar type hints (omg yes)
https://wiki.php.net/rfc/scalar_type_hints_v5
 Weak comparison mode will cast to the type you wish.
 Strict comparison will throw a catchable fatal.
Turn on with declare(strict_types=1);
function sendHttpStatus(int $statusCode, string $message) {
header('HTTP/1.0 ' .$statusCode. ' ' .$message);
}
sendHttpStatus(404, "File Not Found"); // integer and string passed
sendHttpStatus("403", "OK"); // string "403" coerced to int(403)
New Features
 Return Type Hints
 https://wiki.php.net/rfc/return_types
 String, int, float, bool
 Same rules apply with weak and strict modes as parameter
type hints.
New Features
 Combined Comparison Operator
https://wiki.php.net/rfc/combined-comparison-operator
 AKA Starship Operator <=>
 Great for sorting,
returns -1 if value to the right, 0 if same, etc.
// Pre Spacefaring PHP 7
function order_func($a, $b) {
return ($a < $b) ? -1 : (($a > $b) ? 1 : 0);
}
// Post PHP 7
function order_func($a, $b) {
return $a <=> $b;
}
New Features
 Unicode Codepoint Escape Syntax
The addition of a new escape character, u, allows us to specify Unicode
character code points (in hexidecimal) unambiguously inside PHP strings:
The syntax used is u{CODEPOINT}, for example the green heart, 💚,
can be expressed as the PHP string: "u{1F49A}".
New Features
 Null Coalesce Operator
Another new operator, the Null Coalesce Operator, ??
It will return the left operand if it is not NULL, otherwise it will return the right.
The important thing is that it will not raise a notice if the left operand is a non-
existent variable. This is like isset() and unlike the ?: short ternary operator.
You can also chain the operators to return the first non-null of a given set:
$config = $config ?? $this->config ?? static::$defaultConfig;
New Features
 Bind Closure on Call
With PHP 5.4 we saw the addition of Closure->bindTo() and Closure::bind() which
allows you change the binding of $this and the calling scope, together, or separately,
creating a duplicate closure.
PHP 7 now adds an easy way to do this at call time, binding both $this and the calling
scope to the same object with the addition of Closure->call(). This method takes the
object as it’s first argument, followed by any arguments to pass into the closure, like
so:
class HelloWorld { private $greeting = "Hello"; }
$closure = function($whom) { echo $this->greeting . ' ' . $whom; }
$obj = new HelloWorld();
$closure->call($obj, 'World'); // Hello World
New Features
 Group Use Declarations
// Original
use FrameworkComponentSubComponentClassA;
use FrameworkComponentSubComponentClassB as ClassC;
use FrameworkComponentOtherComponentClassD;
// With Group Use
use FrameworkComponent{
SubComponentClassA,
SubComponentClassB as ClassC,
OtherComponentClassD
};
New Features
 Group Use Declarations
It can also be used with constant and function imports with use function, and use const,
as well as supporting mixed imports:
use FrameworkComponent{
SubComponentClassA,
function OtherComponentsomeFunction,
const OtherComponentSOME_CONSTANT
};
New Features
 Generator Return Expressions
There are two new features added to generators. The first is Generator Return
Expressions, which allows you to now return a value upon (successful) completion of a
generator.
Prior to PHP 7, if you tried to return anything, this would result in an error. However,
now you can call $generator->getReturn() to retrieve the return value.
If the generator has not yet returned, or has thrown an uncaught exception, calling
$generator->getReturn() will throw an exception. If the generator has completed but
there was no return, null is returned.
https://wiki.php.net/rfc/generator-return-expressions
New Features
 Generator Return Expressions
function gen() {
yield "Hello";
yield " ";
yield "World!";
return "Goodbye Moon!”;
}
$gen = gen();
foreach ($gen as $value) { echo $value; }
// Outputs "Hello" on iteration 1, " " on iterator 2, and "World!" on iteration 3 echo
$gen->getReturn(); // Goodbye Moon!
https://wiki.php.net/rfc/generator-return-expressions
New Features
 Generator Delegation
The second feature is much more exciting: Generator Delegation. This allows you to
return another iterable structure that can itself be traversed — whether that is an array,
an iterator, or another generator.
It is important to understand that iteration of sub-structures is done by the outer-most
original loop as if it were a single flat structure, rather than a recursive one.
This is also true when sending data or exceptions into a generator. They are passed
directly onto the sub-structure as if it were being controlled directly by the call.
This is done using the yield from <expression> syntax
New Features
 Generator Delegation
function hello() {
yield "Hello";
yield " ";
yield "World!";
yield from goodbye(); }
function goodbye() {
yield "Goodbye";
yield " ";
yield "Moon!"; }
$gen = hello();
foreach ($gen as $value) { echo $value; }
On each iteration, this will output:
"Hello"
" "
"World!”
"Goodbye"
" "
"Moon!"
New Features
 Engine Exceptions
Handling of fatal and catchable fatal errors has traditionally been impossible, or at
least difficult, in PHP. But with the addition of Engine Exceptions, many of these
errors will now throw exceptions instead. Now, when a fatal or catchable fatal error
occurs, it will throw an exception, allowing you to handle it gracefully. If you do
not handle it at all, it will result in a traditional fatal error as an uncaught exception.
These exceptions are EngineException objects, and unlike all userland
exceptions, do not extend the base Exception class. This is to ensure that existing
code that catches the Exception class does not start catching fatal errors moving
forward. It thus maintains backwards compatibility. In the future, if you wish to
catch both traditional exceptions and engine exceptions, you will need to catch
their new shared parent class, BaseException. Additionally, parse errors in
eval()’ed code will throw a ParseException, while type mismatches will throw a
TypeException.
New Features
 Engine Exceptions
try {
nonExistentFunction();
}
catch (EngineException $e) {
var_dump($e);
}
object(EngineException)#1 (7) {
["message":protected]=> string(32) "Call to undefined function nonExistantFunction()"
["string":"BaseException":private]=> string(0) ""
["code":protected]=> int(1)
["file":protected]=> string(17) "engine-exceptions.php" ["line":protected]=> int(1)
["trace":"BaseException":private]=> array(0) { }
["previous":"BaseException":private]=> NULL
}
More Info & Credits
 Slides info from
 https://blog.engineyard.com/2015/what-to-expect-php-7-2
 Infographic
 https://pages.zend.com/ty-infographic.html
 RFC
 https://wiki.php.net/rfc/php7timeline

Weitere ähnliche Inhalte

Was ist angesagt?

PHP traits, treat or threat?
PHP traits, treat or threat?PHP traits, treat or threat?
PHP traits, treat or threat?Nick Belhomme
 
PHP Tips for certification - OdW13
PHP Tips for certification - OdW13PHP Tips for certification - OdW13
PHP Tips for certification - OdW13julien pauli
 
IPC2010SE Doctrine2 Enterprise Persistence Layer for PHP
IPC2010SE Doctrine2 Enterprise Persistence Layer for PHPIPC2010SE Doctrine2 Enterprise Persistence Layer for PHP
IPC2010SE Doctrine2 Enterprise Persistence Layer for PHPGuilherme Blanco
 
Object Trampoline: Why having not the object you want is what you need.
Object Trampoline: Why having not the object you want is what you need.Object Trampoline: Why having not the object you want is what you need.
Object Trampoline: Why having not the object you want is what you need.Workhorse Computing
 
PHP 7 - Above and Beyond
PHP 7 - Above and BeyondPHP 7 - Above and Beyond
PHP 7 - Above and Beyondrafaelfqf
 
Mastering Namespaces in PHP
Mastering Namespaces in PHPMastering Namespaces in PHP
Mastering Namespaces in PHPNick Belhomme
 
Zephir - A Wind of Change for writing PHP extensions
Zephir - A Wind of Change for writing PHP extensionsZephir - A Wind of Change for writing PHP extensions
Zephir - A Wind of Change for writing PHP extensionsMark Baker
 
Zeppelin Helium: Spell
Zeppelin Helium: SpellZeppelin Helium: Spell
Zeppelin Helium: SpellPArk Hoon
 
Perl 5.10 in 2010
Perl 5.10 in 2010Perl 5.10 in 2010
Perl 5.10 in 2010guest7899f0
 
Phpをいじり倒す10の方法
Phpをいじり倒す10の方法Phpをいじり倒す10の方法
Phpをいじり倒す10の方法Moriyoshi Koizumi
 
Php 7.2 compliance workshop php benelux
Php 7.2 compliance workshop php beneluxPhp 7.2 compliance workshop php benelux
Php 7.2 compliance workshop php beneluxDamien Seguy
 
Better detection of what modules are used by some Perl 5 code
Better detection of what modules are used by some Perl 5 codeBetter detection of what modules are used by some Perl 5 code
Better detection of what modules are used by some Perl 5 codecharsbar
 
Voxxed Days Vilnius 2015 - Having fun with Javassist
Voxxed Days Vilnius 2015 - Having fun with JavassistVoxxed Days Vilnius 2015 - Having fun with Javassist
Voxxed Days Vilnius 2015 - Having fun with JavassistAnton Arhipov
 
PHP Barcelona 2010 - Architecture and testability
PHP Barcelona 2010 - Architecture and testabilityPHP Barcelona 2010 - Architecture and testability
PHP Barcelona 2010 - Architecture and testabilityGiorgio Sironi
 
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.4Wim Godden
 

Was ist angesagt? (20)

PHP 5.3
PHP 5.3PHP 5.3
PHP 5.3
 
PHP7 is coming
PHP7 is comingPHP7 is coming
PHP7 is coming
 
PHP traits, treat or threat?
PHP traits, treat or threat?PHP traits, treat or threat?
PHP traits, treat or threat?
 
Getting testy with Perl
Getting testy with PerlGetting testy with Perl
Getting testy with Perl
 
PHP Tips for certification - OdW13
PHP Tips for certification - OdW13PHP Tips for certification - OdW13
PHP Tips for certification - OdW13
 
IPC2010SE Doctrine2 Enterprise Persistence Layer for PHP
IPC2010SE Doctrine2 Enterprise Persistence Layer for PHPIPC2010SE Doctrine2 Enterprise Persistence Layer for PHP
IPC2010SE Doctrine2 Enterprise Persistence Layer for PHP
 
Object Trampoline: Why having not the object you want is what you need.
Object Trampoline: Why having not the object you want is what you need.Object Trampoline: Why having not the object you want is what you need.
Object Trampoline: Why having not the object you want is what you need.
 
PHP 7 - Above and Beyond
PHP 7 - Above and BeyondPHP 7 - Above and Beyond
PHP 7 - Above and Beyond
 
Mastering Namespaces in PHP
Mastering Namespaces in PHPMastering Namespaces in PHP
Mastering Namespaces in PHP
 
Zephir - A Wind of Change for writing PHP extensions
Zephir - A Wind of Change for writing PHP extensionsZephir - A Wind of Change for writing PHP extensions
Zephir - A Wind of Change for writing PHP extensions
 
Zeppelin Helium: Spell
Zeppelin Helium: SpellZeppelin Helium: Spell
Zeppelin Helium: Spell
 
Perl 5.10 in 2010
Perl 5.10 in 2010Perl 5.10 in 2010
Perl 5.10 in 2010
 
Unit Testing Lots of Perl
Unit Testing Lots of PerlUnit Testing Lots of Perl
Unit Testing Lots of Perl
 
Phpをいじり倒す10の方法
Phpをいじり倒す10の方法Phpをいじり倒す10の方法
Phpをいじり倒す10の方法
 
Php 7.2 compliance workshop php benelux
Php 7.2 compliance workshop php beneluxPhp 7.2 compliance workshop php benelux
Php 7.2 compliance workshop php benelux
 
Better detection of what modules are used by some Perl 5 code
Better detection of what modules are used by some Perl 5 codeBetter detection of what modules are used by some Perl 5 code
Better detection of what modules are used by some Perl 5 code
 
Get your teeth into Plack
Get your teeth into PlackGet your teeth into Plack
Get your teeth into Plack
 
Voxxed Days Vilnius 2015 - Having fun with Javassist
Voxxed Days Vilnius 2015 - Having fun with JavassistVoxxed Days Vilnius 2015 - Having fun with Javassist
Voxxed Days Vilnius 2015 - Having fun with Javassist
 
PHP Barcelona 2010 - Architecture and testability
PHP Barcelona 2010 - Architecture and testabilityPHP Barcelona 2010 - Architecture and testability
PHP Barcelona 2010 - Architecture and testability
 
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
 

Andere mochten auch

Last Month in PHP - December 2015
Last Month in PHP - December 2015Last Month in PHP - December 2015
Last Month in PHP - December 2015Eric Poe
 
Doing More With Less
Doing More With LessDoing More With Less
Doing More With LessDavid Engel
 
Harder, Better, Faster, Stronger
Harder, Better, Faster, StrongerHarder, Better, Faster, Stronger
Harder, Better, Faster, StrongerDavid Engel
 
Php 5.4: New Language Features You Will Find Useful
Php 5.4: New Language Features You Will Find UsefulPhp 5.4: New Language Features You Will Find Useful
Php 5.4: New Language Features You Will Find UsefulDavid Engel
 
PHP7 - Scalar Type Hints & Return Types
PHP7 - Scalar Type Hints & Return TypesPHP7 - Scalar Type Hints & Return Types
PHP7 - Scalar Type Hints & Return TypesEric Poe
 
Giới thiệu PHP 7
Giới thiệu PHP 7Giới thiệu PHP 7
Giới thiệu PHP 7ZendVN
 

Andere mochten auch (8)

Last Month in PHP - December 2015
Last Month in PHP - December 2015Last Month in PHP - December 2015
Last Month in PHP - December 2015
 
Key features PHP 5.3 - 5.6
Key features PHP 5.3 - 5.6Key features PHP 5.3 - 5.6
Key features PHP 5.3 - 5.6
 
Doing More With Less
Doing More With LessDoing More With Less
Doing More With Less
 
Cache is King!
Cache is King!Cache is King!
Cache is King!
 
Harder, Better, Faster, Stronger
Harder, Better, Faster, StrongerHarder, Better, Faster, Stronger
Harder, Better, Faster, Stronger
 
Php 5.4: New Language Features You Will Find Useful
Php 5.4: New Language Features You Will Find UsefulPhp 5.4: New Language Features You Will Find Useful
Php 5.4: New Language Features You Will Find Useful
 
PHP7 - Scalar Type Hints & Return Types
PHP7 - Scalar Type Hints & Return TypesPHP7 - Scalar Type Hints & Return Types
PHP7 - Scalar Type Hints & Return Types
 
Giới thiệu PHP 7
Giới thiệu PHP 7Giới thiệu PHP 7
Giới thiệu PHP 7
 

Ähnlich wie PHP 7

Introducing PHP Latest Updates
Introducing PHP Latest UpdatesIntroducing PHP Latest Updates
Introducing PHP Latest UpdatesIftekhar Eather
 
Php 7 compliance workshop singapore
Php 7 compliance workshop singaporePhp 7 compliance workshop singapore
Php 7 compliance workshop singaporeDamien Seguy
 
Free PHP Book Online | PHP Development in India
Free PHP Book Online | PHP Development in IndiaFree PHP Book Online | PHP Development in India
Free PHP Book Online | PHP Development in IndiaDeepak Rajput
 
Building and Incredible Machine with Pipelines and Generators in PHP (IPC Ber...
Building and Incredible Machine with Pipelines and Generators in PHP (IPC Ber...Building and Incredible Machine with Pipelines and Generators in PHP (IPC Ber...
Building and Incredible Machine with Pipelines and Generators in PHP (IPC Ber...dantleech
 
Last train to php 7
Last train to php 7Last train to php 7
Last train to php 7Damien Seguy
 
What To Expect From PHP7
What To Expect From PHP7What To Expect From PHP7
What To Expect From PHP7Codemotion
 
PHP MATERIAL
PHP MATERIALPHP MATERIAL
PHP MATERIALzatax
 
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
 
Fighting Fear-Driven-Development With PHPUnit
Fighting Fear-Driven-Development With PHPUnitFighting Fear-Driven-Development With PHPUnit
Fighting Fear-Driven-Development With PHPUnitJames Fuller
 
Object Oriented PHP - PART-2
Object Oriented PHP - PART-2Object Oriented PHP - PART-2
Object Oriented PHP - PART-2Jalpesh Vasa
 
Ch ch-changes cake php2
Ch ch-changes cake php2Ch ch-changes cake php2
Ch ch-changes cake php2markstory
 
The why and how of moving to PHP 5.4/5.5
The why and how of moving to PHP 5.4/5.5The why and how of moving to PHP 5.4/5.5
The why and how of moving to PHP 5.4/5.5Wim Godden
 
Advanced Perl Techniques
Advanced Perl TechniquesAdvanced Perl Techniques
Advanced Perl TechniquesDave Cross
 
Anatomy of a PHP Request ( UTOSC 2010 )
Anatomy of a PHP Request ( UTOSC 2010 )Anatomy of a PHP Request ( UTOSC 2010 )
Anatomy of a PHP Request ( UTOSC 2010 )Joseph Scott
 
The why and how of moving to PHP 5.5/5.6
The why and how of moving to PHP 5.5/5.6The why and how of moving to PHP 5.5/5.6
The why and how of moving to PHP 5.5/5.6Wim Godden
 
Php Chapter 1 Training
Php Chapter 1 TrainingPhp Chapter 1 Training
Php Chapter 1 TrainingChris Chubb
 
New Stuff In Php 5.3
New Stuff In Php 5.3New Stuff In Php 5.3
New Stuff In Php 5.3Chris Chubb
 

Ähnlich wie PHP 7 (20)

Introducing PHP Latest Updates
Introducing PHP Latest UpdatesIntroducing PHP Latest Updates
Introducing PHP Latest Updates
 
Php 7 compliance workshop singapore
Php 7 compliance workshop singaporePhp 7 compliance workshop singapore
Php 7 compliance workshop singapore
 
Free PHP Book Online | PHP Development in India
Free PHP Book Online | PHP Development in IndiaFree PHP Book Online | PHP Development in India
Free PHP Book Online | PHP Development in India
 
Building and Incredible Machine with Pipelines and Generators in PHP (IPC Ber...
Building and Incredible Machine with Pipelines and Generators in PHP (IPC Ber...Building and Incredible Machine with Pipelines and Generators in PHP (IPC Ber...
Building and Incredible Machine with Pipelines and Generators in PHP (IPC Ber...
 
Last train to php 7
Last train to php 7Last train to php 7
Last train to php 7
 
What To Expect From PHP7
What To Expect From PHP7What To Expect From PHP7
What To Expect From PHP7
 
PHP MATERIAL
PHP MATERIALPHP MATERIAL
PHP MATERIAL
 
PHP Reviewer
PHP ReviewerPHP Reviewer
PHP Reviewer
 
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)
 
Fighting Fear-Driven-Development With PHPUnit
Fighting Fear-Driven-Development With PHPUnitFighting Fear-Driven-Development With PHPUnit
Fighting Fear-Driven-Development With PHPUnit
 
Object Oriented PHP - PART-2
Object Oriented PHP - PART-2Object Oriented PHP - PART-2
Object Oriented PHP - PART-2
 
Ch ch-changes cake php2
Ch ch-changes cake php2Ch ch-changes cake php2
Ch ch-changes cake php2
 
The why and how of moving to PHP 5.4/5.5
The why and how of moving to PHP 5.4/5.5The why and how of moving to PHP 5.4/5.5
The why and how of moving to PHP 5.4/5.5
 
Advanced Perl Techniques
Advanced Perl TechniquesAdvanced Perl Techniques
Advanced Perl Techniques
 
New in php 7
New in php 7New in php 7
New in php 7
 
Migrating to PHP 7
Migrating to PHP 7Migrating to PHP 7
Migrating to PHP 7
 
Anatomy of a PHP Request ( UTOSC 2010 )
Anatomy of a PHP Request ( UTOSC 2010 )Anatomy of a PHP Request ( UTOSC 2010 )
Anatomy of a PHP Request ( UTOSC 2010 )
 
The why and how of moving to PHP 5.5/5.6
The why and how of moving to PHP 5.5/5.6The why and how of moving to PHP 5.5/5.6
The why and how of moving to PHP 5.5/5.6
 
Php Chapter 1 Training
Php Chapter 1 TrainingPhp Chapter 1 Training
Php Chapter 1 Training
 
New Stuff In Php 5.3
New Stuff In Php 5.3New Stuff In Php 5.3
New Stuff In Php 5.3
 

Mehr von Joshua Copeland

Mehr von Joshua Copeland (7)

Web scraping 101 with goutte
Web scraping 101 with goutteWeb scraping 101 with goutte
Web scraping 101 with goutte
 
WooCommerce
WooCommerceWooCommerce
WooCommerce
 
Universal Windows Platform Overview
Universal Windows Platform OverviewUniversal Windows Platform Overview
Universal Windows Platform Overview
 
LVPHP.org
LVPHP.orgLVPHP.org
LVPHP.org
 
PHP Rocketeer
PHP RocketeerPHP Rocketeer
PHP Rocketeer
 
Blackfire
BlackfireBlackfire
Blackfire
 
Lumen
LumenLumen
Lumen
 

Kürzlich hochgeladen

The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfayushiqss
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionOnePlan Solutions
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...Nitya salvi
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park masabamasaba
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456KiaraTiradoMicha
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxBUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxalwaysnagaraju26
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesVictorSzoltysek
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verifiedSector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verifiedDelhi Call girls
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfkalichargn70th171
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is insideshinachiaurasa2
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...kalichargn70th171
 

Kürzlich hochgeladen (20)

The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxBUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verifiedSector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 

PHP 7

  • 1. PHP 7 What’s new in PHP 7 By: Joshua Copeland
  • 2. Joshua Copeland  PHP lover for 7+ years  Lead Developer at The Selling Source (we need a DBA)  Father, husband, and overall awesome guy  Software Developer for over 10 years  First human to be a computer  My Twitter Handle : @PsyCodeDotOrg
  • 3. Proposed Milestones  1. Line up any remaining RFCs that target PHP 7.0.  2. Finalize implementation & testing of new features. Mar 16 - Jun 15 (3 months)  3. Release Candidate (RC) cycles Jun 16 - Oct 15 (3 months)  4. GA/Release Mid October 2015  https://wiki.php.net/rfc/php7timeline
  • 4. Inconsistency Fixes  Abstract Syntax Tree (AST)  Decoupled the parser from the compiler.  list() currently assigns variables right-to-left, the AST implementation will assign them left-to-right instead.  Auto-vivification order for by-reference assignments.  10-15% faster compile times, but requires more memory.  Directly calling __clone is allowed https://wiki.php.net/rfc/abstract_syntax_tree
  • 5. Uniform Variable Syntax  Introduction of an internally consistent and complete variable syntax. To achieve this goal the semantics of some rarely used variable-variable constructions need to be changed.  Call closures assigned to properties using ($object->closureProperty)()  Chain static calls. Ex: $foo::$bar::$bat  Semantics when using variable-variables/properties  https://wiki.php.net/rfc/uniform_variable_syntax
  • 7. Biggest reason to update Performance! PHP 7 is on par with HHVM Memory Savings
  • 8. Backwards Incompatible Changes  Call to member function on a non-object now catchable fatal error. https://wiki.php.net/rfc/catchable-call-to-member-of-non-object  ASP and script tags have been removed Ex. <% <%= <script language=“php”></script>  Removal of all deprecated functionality. https://wiki.php.net/rfc/remove_deprecated_functionality_in_php7  Removal of the POSIX compatible regular expressions extension, ext/ereg (deprecated in 5.3) and the old ext/mysql extension (deprecated in 5.5).  Switch statements throw and error when more than one default case found.
  • 9. New Features  Scalar type hints (omg yes) https://wiki.php.net/rfc/scalar_type_hints_v5  Weak comparison mode will cast to the type you wish.  Strict comparison will throw a catchable fatal. Turn on with declare(strict_types=1); function sendHttpStatus(int $statusCode, string $message) { header('HTTP/1.0 ' .$statusCode. ' ' .$message); } sendHttpStatus(404, "File Not Found"); // integer and string passed sendHttpStatus("403", "OK"); // string "403" coerced to int(403)
  • 10. New Features  Return Type Hints  https://wiki.php.net/rfc/return_types  String, int, float, bool  Same rules apply with weak and strict modes as parameter type hints.
  • 11. New Features  Combined Comparison Operator https://wiki.php.net/rfc/combined-comparison-operator  AKA Starship Operator <=>  Great for sorting, returns -1 if value to the right, 0 if same, etc. // Pre Spacefaring PHP 7 function order_func($a, $b) { return ($a < $b) ? -1 : (($a > $b) ? 1 : 0); } // Post PHP 7 function order_func($a, $b) { return $a <=> $b; }
  • 12. New Features  Unicode Codepoint Escape Syntax The addition of a new escape character, u, allows us to specify Unicode character code points (in hexidecimal) unambiguously inside PHP strings: The syntax used is u{CODEPOINT}, for example the green heart, 💚, can be expressed as the PHP string: "u{1F49A}".
  • 13. New Features  Null Coalesce Operator Another new operator, the Null Coalesce Operator, ?? It will return the left operand if it is not NULL, otherwise it will return the right. The important thing is that it will not raise a notice if the left operand is a non- existent variable. This is like isset() and unlike the ?: short ternary operator. You can also chain the operators to return the first non-null of a given set: $config = $config ?? $this->config ?? static::$defaultConfig;
  • 14. New Features  Bind Closure on Call With PHP 5.4 we saw the addition of Closure->bindTo() and Closure::bind() which allows you change the binding of $this and the calling scope, together, or separately, creating a duplicate closure. PHP 7 now adds an easy way to do this at call time, binding both $this and the calling scope to the same object with the addition of Closure->call(). This method takes the object as it’s first argument, followed by any arguments to pass into the closure, like so: class HelloWorld { private $greeting = "Hello"; } $closure = function($whom) { echo $this->greeting . ' ' . $whom; } $obj = new HelloWorld(); $closure->call($obj, 'World'); // Hello World
  • 15. New Features  Group Use Declarations // Original use FrameworkComponentSubComponentClassA; use FrameworkComponentSubComponentClassB as ClassC; use FrameworkComponentOtherComponentClassD; // With Group Use use FrameworkComponent{ SubComponentClassA, SubComponentClassB as ClassC, OtherComponentClassD };
  • 16. New Features  Group Use Declarations It can also be used with constant and function imports with use function, and use const, as well as supporting mixed imports: use FrameworkComponent{ SubComponentClassA, function OtherComponentsomeFunction, const OtherComponentSOME_CONSTANT };
  • 17. New Features  Generator Return Expressions There are two new features added to generators. The first is Generator Return Expressions, which allows you to now return a value upon (successful) completion of a generator. Prior to PHP 7, if you tried to return anything, this would result in an error. However, now you can call $generator->getReturn() to retrieve the return value. If the generator has not yet returned, or has thrown an uncaught exception, calling $generator->getReturn() will throw an exception. If the generator has completed but there was no return, null is returned. https://wiki.php.net/rfc/generator-return-expressions
  • 18. New Features  Generator Return Expressions function gen() { yield "Hello"; yield " "; yield "World!"; return "Goodbye Moon!”; } $gen = gen(); foreach ($gen as $value) { echo $value; } // Outputs "Hello" on iteration 1, " " on iterator 2, and "World!" on iteration 3 echo $gen->getReturn(); // Goodbye Moon! https://wiki.php.net/rfc/generator-return-expressions
  • 19. New Features  Generator Delegation The second feature is much more exciting: Generator Delegation. This allows you to return another iterable structure that can itself be traversed — whether that is an array, an iterator, or another generator. It is important to understand that iteration of sub-structures is done by the outer-most original loop as if it were a single flat structure, rather than a recursive one. This is also true when sending data or exceptions into a generator. They are passed directly onto the sub-structure as if it were being controlled directly by the call. This is done using the yield from <expression> syntax
  • 20. New Features  Generator Delegation function hello() { yield "Hello"; yield " "; yield "World!"; yield from goodbye(); } function goodbye() { yield "Goodbye"; yield " "; yield "Moon!"; } $gen = hello(); foreach ($gen as $value) { echo $value; } On each iteration, this will output: "Hello" " " "World!” "Goodbye" " " "Moon!"
  • 21. New Features  Engine Exceptions Handling of fatal and catchable fatal errors has traditionally been impossible, or at least difficult, in PHP. But with the addition of Engine Exceptions, many of these errors will now throw exceptions instead. Now, when a fatal or catchable fatal error occurs, it will throw an exception, allowing you to handle it gracefully. If you do not handle it at all, it will result in a traditional fatal error as an uncaught exception. These exceptions are EngineException objects, and unlike all userland exceptions, do not extend the base Exception class. This is to ensure that existing code that catches the Exception class does not start catching fatal errors moving forward. It thus maintains backwards compatibility. In the future, if you wish to catch both traditional exceptions and engine exceptions, you will need to catch their new shared parent class, BaseException. Additionally, parse errors in eval()’ed code will throw a ParseException, while type mismatches will throw a TypeException.
  • 22. New Features  Engine Exceptions try { nonExistentFunction(); } catch (EngineException $e) { var_dump($e); } object(EngineException)#1 (7) { ["message":protected]=> string(32) "Call to undefined function nonExistantFunction()" ["string":"BaseException":private]=> string(0) "" ["code":protected]=> int(1) ["file":protected]=> string(17) "engine-exceptions.php" ["line":protected]=> int(1) ["trace":"BaseException":private]=> array(0) { } ["previous":"BaseException":private]=> NULL }
  • 23. More Info & Credits  Slides info from  https://blog.engineyard.com/2015/what-to-expect-php-7-2  Infographic  https://pages.zend.com/ty-infographic.html  RFC  https://wiki.php.net/rfc/php7timeline