Php 5.6 From the Inside Out

Ferenc Kovács
Ferenc Kovácsdeveloper at ustream.tv
PHP 5.6 
From The Inside Out
Introduction 
● Ferenc Kovacs 
○ DevOps guy from Budapest, Hungary 
○ Infrastructure Engineer at http://www.ustream.tv/ 
○ Volunteer for the PHP project since 2011 
○ Release Manager for PHP 5.6 with Julien Pauli
History of PHP 5.6 
● 2012-11-09: First commit 
● 2013-11-06: PHP-5.6 branched out 
● 2014-01-23: PHP-5.6.0alpha1(rfc freeze) 
● 2014-04-11: PHP-5.6.0beta1(feature freeze) 
● 2014-06-19: PHP-5.6.0RC1 
● 2014-08-28: PHP-5.6.0
Some stats about the changes 
Version Released Commits Authors LOC added LOC deleted 
5.3.0 2009-06-30 5339 83 1575768 756904 
5.4.0 2012-03-01 18779 135 3701590 2150397 
5.5.0 2013-06-20 2842 113 287785 164481 
5.6.0 2014-08-28 2013 107 496200 1235336 
7.0 N/A 3671 90 531825 1315925
Release Process 
https://wiki.php.net/rfc/releaseprocess 
tl;dr: 
● yearly release schedule(timeboxing), 2+1 
year support cycle. 
● guidelines about what is allowed in a 
major/minor/micro version. 
● resulting smaller, more predictable releases 
which are easier to upgrade to.
Changes in 5.6 
1. BC breaks 
2. New features 
3. Deprecated features
BC breaks 
● json_decode() only accepts lowercase for 
true/false/null to follow the JSON spec. 
● Stream wrappers now verify peer certificates 
and host names by default when using 
SSL/TLS. 
● GMP resources are now objects. 
● Mcrypt functions now require valid keys and 
IVs.
BC breaks 
● unserialize() now validates the serialize 
format for classes implementing Serializable. 
○ class Foo 
■ O:3:"Foo":0:{} 
○ class Foo implements Serializable 
■ C:3:"Foo":4:{r:1;} 
○ Can be a problem if you handcrafting the strings 
(PHPUnit, Doctrine) or storing those somewhere and 
the class definition changes(Horde).
BC breaks 
● using the @file syntax for curl file uploads 
are only supported if option 
CURLOPT_SAFE_UPLOAD is set to false. 
CURLFile should be used instead.
BC breaks 
<?php 
class C { 
const ONE = 1; 
public $array = [ 
self::ONE => 'foo', 
'bar', 
'quux', 
]; 
} 
count((new C)->array); // 2 on <=5.5 but 3 on >=5.6 
?>
New features 
The big ones 
● Constant scalar expressions 
● Variadic functions 
● Argument unpacking 
● Power operator 
● use function and use const 
● phpdbg 
● SSL/TLS improvements
Constant scalar expressions 
<?php 
const ONE = 1; 
const TWO = ONE * 2; 
class C { 
const THREE = TWO + 1; 
const ONE_THIRD = ONE / self::THREE; 
const SENTENCE = 'The value of THREE is '.self::THREE; 
public function f($a = ONE + self::THREE) { 
return $a; 
} 
} 
echo (new C)->f()."n"; // 4 
echo C::SENTENCE; // The value of THREE is 3 
?>
Variadic functions 
<?php 
function f($req, $opt = null, ...$params) { 
// $params is an array containing the remaining arguments. 
printf('$req: %d; $opt: %d; number of params: %d'."n", 
$req, $opt, count($params)); 
} 
f(1); // $req: 1; $opt: 0; number of params: 0 
f(1, 2); // $req: 1; $opt: 2; number of params: 0 
f(1, 2, 3); // $req: 1; $opt: 2; number of params: 1 
f(1, 2, 3, 4); // $req: 1; $opt: 2; number of params: 2 
f(1, 2, 3, 4, 5); // $req: 1; $opt: 2; number of params: 3 
?>
Argument Unpacking 
<?php 
function add($a, $b, $c) { 
return $a + $b + $c; 
} 
$operators = [2, 3]; 
echo add(1, ...$operators); // 6 
?>
Power operator 
<?php 
printf("2 ** 3 == %dn", 2 ** 3); // 2** 3 == 8 
printf("2 ** 3 ** 2 == %dn", 2 ** 3 ** 2); // 2 ** 3 ** 2 == 512 
$a = 2; 
$a **= 3; 
printf("a == %dn", $a); // a == 8 
?>
use function and use const 
<?php 
namespace NameSpace { 
const FOO = 42; 
function f() { echo __FUNCTION__."n"; } 
} 
namespace { 
use const NameSpaceFOO; 
use function NameSpacef; 
echo FOO."n"; // 42 
f(); // NameSpacef 
} 
?>
phpdbg 
New SAPI for debugging php scripts 
● really handy for debugging cli scripts or 
debugging without an IDE. 
● no out-of-the-box solution for debugging web 
requests(WIP). 
● no IDE integration yet(WIP). 
● those familiar with gdb will probably like it.
phpdbg features 
● list source for line/function/method/class 
● show info about current 
files/classes/functions/etc. 
● print opcodes for classes/functions/current 
execution context, etc. 
● traverse and sho information about 
stackframes
phpdbg features 
● show the current backtrace. 
● set execution context. 
● run the current execution context. 
● step through the execution. 
● continue the execution until the next 
breakpoint/watchpoint. 
● continue the execution until the next 
breakpoint/watchpoint after the given line.
phpdbg features 
● continue the execution skipping any 
breakpoint/watchpoint until the current frame 
is finished. 
● continue the execution skipping any 
breakpoint/watchpoint to right before we 
leave the current frame.
phpdbg features 
● set a conditional expression on the target 
where execution will break if the expression 
evaluates true. 
● set a watchpoint on variable. 
● clear breakpoints. 
● clean up the execution environment(remove 
constant/function/class definitions).
phpdbg features 
● set the phpdbg configuration. 
● source a phpdbginit script. 
● register a phpdbginit function as an alias. 
● shell a command. 
● evaluate some code. 
● quit.
SSL/TLS improvements 
● Stream wrappers now verify peer certificates 
and host names by default when using 
SSL/TLS. 
● Added support SAN x509 extension 
matching for verifying host names in 
encrypted streams. 
● New SSL context options for improved 
stream server security.
SSL/TLS improvements 
● Added support for Server Name Indication. 
● Added protocol-specific encryption stream 
wrappers (tlsv1.0://, tlsv1.1:// and tlsv1.2://). 
● Added support for managing SPKAC/SPKI.
Other features 
● __debugInfo() magic method for intercepting 
var_dump(); 
● php://input is reusable 
● Large file uploads (>2GB) are now accepted. 
● The new GMP objects now support operator 
overloading. 
● hash_equals() for constant time string 
comparison.
Other features 
● gost-crypto hash algo was added. 
● PostgreSQL async support 
○ pg_connect($dsn, PGSQL_CONNECT_ASYNC); 
○ pg_connect_poll(); 
○ pg_socket(); 
○ pg_consume_input(); 
○ pg_flush(); 
● ReflectionClass:: 
newInstanceWithoutConstructor() can 
instantiate almost everything.
Other features 
● The default value for default_charset 
changed to UTF-8, html* iconv* and 
mbstring* function will use this value when 
no explicit encoding is set/passed. 
● New fetching mode for mysqlnd, controlled 
via mysqlnd.fetch_data_copy. 
○ Will use less memory but do more copying.
Deprecated features 
● Calls from incompatible context will now emit 
E_DEPRECATED instead of E_STRICT 
● always_populate_raw_post_data now have 
a new value(-1), which completely disables 
the population of 
$HTTP_RAW_POST_DATA, setting it 
anything else will emit an E_DEPRECATED.
Deprecated features 
● The following settings are all deprecated in 
favor of default_charset: 
○ iconv.input_encoding 
○ iconv.output_encoding 
○ iconv.internal_encoding 
○ mbstring.http_input 
○ mbstring.http_output 
○ mbstring.internal_encoding
Thanks for your attention! 
Slides will be here: 
http://www.slideshare.net/Tyrael 
If you have any questions: 
tyrael@php.net 
@Tyr43l
1 of 30

Recommended

Writing MySQL UDFs by
Writing MySQL UDFsWriting MySQL UDFs
Writing MySQL UDFsRoland Bouman
10.8K views24 slides
ClojureScript loves React, DomCode May 26 2015 by
ClojureScript loves React, DomCode May 26 2015ClojureScript loves React, DomCode May 26 2015
ClojureScript loves React, DomCode May 26 2015Michiel Borkent
411 views52 slides
ClojureScript for the web by
ClojureScript for the webClojureScript for the web
ClojureScript for the webMichiel Borkent
758 views51 slides
Full Stack Clojure by
Full Stack ClojureFull Stack Clojure
Full Stack ClojureMichiel Borkent
2K views33 slides
2. writing MySql plugins general by
2. writing MySql plugins   general2. writing MySql plugins   general
2. writing MySql plugins generalRoland Bouman
744 views11 slides
Rcpp11 by
Rcpp11Rcpp11
Rcpp11Romain Francois
1.5K views31 slides

More Related Content

What's hot

Advanced Replication Internals by
Advanced Replication InternalsAdvanced Replication Internals
Advanced Replication InternalsScott Hernandez
638 views29 slides
Oracle RDBMS Workshop (Part1) by
Oracle RDBMS Workshop (Part1)Oracle RDBMS Workshop (Part1)
Oracle RDBMS Workshop (Part1)Taras Lyuklyanchuk
519 views30 slides
Profiling and optimizing go programs by
Profiling and optimizing go programsProfiling and optimizing go programs
Profiling and optimizing go programsBadoo Development
8K views84 slides
A new way to develop with WordPress! by
A new way to develop with WordPress!A new way to develop with WordPress!
A new way to develop with WordPress!David Sanchez
663 views19 slides
OTcl and C++ linkages in NS2 by
OTcl and C++ linkages in NS2OTcl and C++ linkages in NS2
OTcl and C++ linkages in NS2Pradeep Kumar TS
4K views14 slides
Getting by with just psql by
Getting by with just psqlGetting by with just psql
Getting by with just psqlCorey Huinker
259 views28 slides

What's hot(20)

A new way to develop with WordPress! by David Sanchez
A new way to develop with WordPress!A new way to develop with WordPress!
A new way to develop with WordPress!
David Sanchez663 views
Getting by with just psql by Corey Huinker
Getting by with just psqlGetting by with just psql
Getting by with just psql
Corey Huinker259 views
Etl confessions pg conf us 2017 by Corey Huinker
Etl confessions   pg conf us 2017Etl confessions   pg conf us 2017
Etl confessions pg conf us 2017
Corey Huinker309 views
3. writing MySql plugins for the information schema by Roland Bouman
3. writing MySql plugins for the information schema3. writing MySql plugins for the information schema
3. writing MySql plugins for the information schema
Roland Bouman652 views
Php 5.6 vs Php 7 performance comparison by Tu Pham
Php 5.6 vs Php 7 performance comparisonPhp 5.6 vs Php 7 performance comparison
Php 5.6 vs Php 7 performance comparison
Tu Pham1.1K views
PHP 7X New Features by Thanh Tai
PHP 7X New FeaturesPHP 7X New Features
PHP 7X New Features
Thanh Tai422 views
Optimizing mysql stored routines uc2010 by Roland Bouman
Optimizing mysql stored routines uc2010Optimizing mysql stored routines uc2010
Optimizing mysql stored routines uc2010
Roland Bouman730 views
PHP7 - Scalar Type Hints & Return Types by Eric Poe
PHP7 - Scalar Type Hints & Return TypesPHP7 - Scalar Type Hints & Return Types
PHP7 - Scalar Type Hints & Return Types
Eric Poe3.5K views
MongoDB 2.8 Replication Internals: Fitting it all together by Scott Hernandez
MongoDB 2.8 Replication Internals: Fitting it all togetherMongoDB 2.8 Replication Internals: Fitting it all together
MongoDB 2.8 Replication Internals: Fitting it all together
Scott Hernandez794 views
HKG15-211: Advanced Toolchain Usage Part 4 by Linaro
HKG15-211: Advanced Toolchain Usage Part 4HKG15-211: Advanced Toolchain Usage Part 4
HKG15-211: Advanced Toolchain Usage Part 4
Linaro4.2K views
The Ring programming language version 1.5.4 book - Part 78 of 185 by Mahmoud Samir Fayed
The Ring programming language version 1.5.4 book - Part 78 of 185The Ring programming language version 1.5.4 book - Part 78 of 185
The Ring programming language version 1.5.4 book - Part 78 of 185
Runtime Symbol Resolution by Ken Kawamoto
Runtime Symbol ResolutionRuntime Symbol Resolution
Runtime Symbol Resolution
Ken Kawamoto8.7K views

Similar to Php 5.6 From the Inside Out

PHP7 Presentation by
PHP7 PresentationPHP7 Presentation
PHP7 PresentationDavid Sanchez
1.4K views23 slides
More on bpftrace for MariaDB DBAs and Developers - FOSDEM 2022 MariaDB Devroom by
More on bpftrace for MariaDB DBAs and Developers - FOSDEM 2022 MariaDB DevroomMore on bpftrace for MariaDB DBAs and Developers - FOSDEM 2022 MariaDB Devroom
More on bpftrace for MariaDB DBAs and Developers - FOSDEM 2022 MariaDB DevroomValeriy Kravchuk
179 views16 slides
PHP 5.6 New and Deprecated Features by
PHP 5.6  New and Deprecated FeaturesPHP 5.6  New and Deprecated Features
PHP 5.6 New and Deprecated FeaturesMark Niebergall
3.2K views28 slides
.NET @ apache.org by
 .NET @ apache.org .NET @ apache.org
.NET @ apache.orgTed Husted
1.5K views74 slides
Continuous Go Profiling & Observability by
Continuous Go Profiling & ObservabilityContinuous Go Profiling & Observability
Continuous Go Profiling & ObservabilityScyllaDB
852 views40 slides
PHP Development Tools by
PHP  Development ToolsPHP  Development Tools
PHP Development ToolsAntony Abramchenko
341 views39 slides

Similar to Php 5.6 From the Inside Out(20)

More on bpftrace for MariaDB DBAs and Developers - FOSDEM 2022 MariaDB Devroom by Valeriy Kravchuk
More on bpftrace for MariaDB DBAs and Developers - FOSDEM 2022 MariaDB DevroomMore on bpftrace for MariaDB DBAs and Developers - FOSDEM 2022 MariaDB Devroom
More on bpftrace for MariaDB DBAs and Developers - FOSDEM 2022 MariaDB Devroom
Valeriy Kravchuk179 views
PHP 5.6 New and Deprecated Features by Mark Niebergall
PHP 5.6  New and Deprecated FeaturesPHP 5.6  New and Deprecated Features
PHP 5.6 New and Deprecated Features
Mark Niebergall3.2K views
.NET @ apache.org by Ted Husted
 .NET @ apache.org .NET @ apache.org
.NET @ apache.org
Ted Husted1.5K views
Continuous Go Profiling & Observability by ScyllaDB
Continuous Go Profiling & ObservabilityContinuous Go Profiling & Observability
Continuous Go Profiling & Observability
ScyllaDB852 views
GopherCon IL 2020 - Web Application Profiling 101 by yinonavraham
GopherCon IL 2020 - Web Application Profiling 101GopherCon IL 2020 - Web Application Profiling 101
GopherCon IL 2020 - Web Application Profiling 101
yinonavraham115 views
The why and how of moving to php 5.4 by Wim Godden
The why and how of moving to php 5.4The why and how of moving to php 5.4
The why and how of moving to php 5.4
Wim Godden2.6K views
Monitoring Kafka w/ Prometheus by kawamuray
Monitoring Kafka w/ PrometheusMonitoring Kafka w/ Prometheus
Monitoring Kafka w/ Prometheus
kawamuray22.5K views
The beautyandthebeast phpbat2010 by Bastian Feder
The beautyandthebeast phpbat2010The beautyandthebeast phpbat2010
The beautyandthebeast phpbat2010
Bastian Feder1.1K views
The why and how of moving to PHP 5.5/5.6 by Wim Godden
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
Wim Godden23.1K views
The why and how of moving to PHP 5.4/5.5 by Wim Godden
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
Wim Godden9.5K views
Introducing PHP Latest Updates by Iftekhar Eather
Introducing PHP Latest UpdatesIntroducing PHP Latest Updates
Introducing PHP Latest Updates
Iftekhar Eather1.3K views
An introduction to PHP 5.4 by Giovanni Derks
An introduction to PHP 5.4An introduction to PHP 5.4
An introduction to PHP 5.4
Giovanni Derks2.5K views
Php in 2013 (Web-5 2013 conference) by julien pauli
Php in 2013 (Web-5 2013 conference)Php in 2013 (Web-5 2013 conference)
Php in 2013 (Web-5 2013 conference)
julien pauli2.8K views
Living With Legacy Code by Rowan Merewood
Living With Legacy CodeLiving With Legacy Code
Living With Legacy Code
Rowan Merewood25.3K views
"Swoole: double troubles in c", Alexandr Vronskiy by Fwdays
"Swoole: double troubles in c", Alexandr Vronskiy"Swoole: double troubles in c", Alexandr Vronskiy
"Swoole: double troubles in c", Alexandr Vronskiy
Fwdays872 views
High Availability PostgreSQL with Zalando Patroni by Zalando Technology
High Availability PostgreSQL with Zalando PatroniHigh Availability PostgreSQL with Zalando Patroni
High Availability PostgreSQL with Zalando Patroni
Zalando Technology25K views
Debugging: Rules And Tools - PHPTek 11 Version by Ian Barber
Debugging: Rules And Tools - PHPTek 11 VersionDebugging: Rules And Tools - PHPTek 11 Version
Debugging: Rules And Tools - PHPTek 11 Version
Ian Barber1.5K views

More from Ferenc Kovács

Collaborative Terraform with Atlantis by
Collaborative Terraform with AtlantisCollaborative Terraform with Atlantis
Collaborative Terraform with AtlantisFerenc Kovács
74 views24 slides
Monitorama by
MonitoramaMonitorama
MonitoramaFerenc Kovács
756 views19 slides
A PHP 5.5 újdonságai. by
A PHP 5.5 újdonságai.A PHP 5.5 újdonságai.
A PHP 5.5 újdonságai.Ferenc Kovács
1.8K views27 slides
Php 5.5 by
Php 5.5Php 5.5
Php 5.5Ferenc Kovács
1.2K views17 slides
A PHP 5.4 újdonságai by
A PHP 5.4 újdonságaiA PHP 5.4 újdonságai
A PHP 5.4 újdonságaiFerenc Kovács
2K views45 slides
Biztonságos webalkalmazások fejlesztése by
Biztonságos webalkalmazások fejlesztéseBiztonságos webalkalmazások fejlesztése
Biztonságos webalkalmazások fejlesztéseFerenc Kovács
6.3K views37 slides

More from Ferenc Kovács(8)

Collaborative Terraform with Atlantis by Ferenc Kovács
Collaborative Terraform with AtlantisCollaborative Terraform with Atlantis
Collaborative Terraform with Atlantis
Ferenc Kovács74 views
Biztonságos webalkalmazások fejlesztése by Ferenc Kovács
Biztonságos webalkalmazások fejlesztéseBiztonságos webalkalmazások fejlesztése
Biztonságos webalkalmazások fejlesztése
Ferenc Kovács6.3K views
Webalkalmazások teljesítményoptimalizálása by Ferenc Kovács
Webalkalmazások teljesítményoptimalizálásaWebalkalmazások teljesítményoptimalizálása
Webalkalmazások teljesítményoptimalizálása
Ferenc Kovács6K views
PHP alkalmazások minőségbiztosítása by Ferenc Kovács
PHP alkalmazások minőségbiztosításaPHP alkalmazások minőségbiztosítása
PHP alkalmazások minőségbiztosítása
Ferenc Kovács1.5K views

Recently uploaded

SUPPLIER SOURCING.pptx by
SUPPLIER SOURCING.pptxSUPPLIER SOURCING.pptx
SUPPLIER SOURCING.pptxangelicacueva6
16 views1 slide
Ransomware is Knocking your Door_Final.pdf by
Ransomware is Knocking your Door_Final.pdfRansomware is Knocking your Door_Final.pdf
Ransomware is Knocking your Door_Final.pdfSecurity Bootcamp
59 views46 slides
Powerful Google developer tools for immediate impact! (2023-24) by
Powerful Google developer tools for immediate impact! (2023-24)Powerful Google developer tools for immediate impact! (2023-24)
Powerful Google developer tools for immediate impact! (2023-24)wesley chun
10 views38 slides
MVP and prioritization.pdf by
MVP and prioritization.pdfMVP and prioritization.pdf
MVP and prioritization.pdfrahuldharwal141
31 views8 slides
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f... by
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...TrustArc
11 views29 slides
Info Session November 2023.pdf by
Info Session November 2023.pdfInfo Session November 2023.pdf
Info Session November 2023.pdfAleksandraKoprivica4
13 views15 slides

Recently uploaded(20)

Powerful Google developer tools for immediate impact! (2023-24) by wesley chun
Powerful Google developer tools for immediate impact! (2023-24)Powerful Google developer tools for immediate impact! (2023-24)
Powerful Google developer tools for immediate impact! (2023-24)
wesley chun10 views
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f... by TrustArc
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...
TrustArc11 views
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLive by Network Automation Forum
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLiveAutomating a World-Class Technology Conference; Behind the Scenes of CiscoLive
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLive
PharoJS - Zürich Smalltalk Group Meetup November 2023 by Noury Bouraqadi
PharoJS - Zürich Smalltalk Group Meetup November 2023PharoJS - Zürich Smalltalk Group Meetup November 2023
PharoJS - Zürich Smalltalk Group Meetup November 2023
Noury Bouraqadi132 views
Igniting Next Level Productivity with AI-Infused Data Integration Workflows by Safe Software
Igniting Next Level Productivity with AI-Infused Data Integration Workflows Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Safe Software280 views
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N... by James Anderson
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
James Anderson92 views
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas... by Bernd Ruecker
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
Bernd Ruecker40 views
Business Analyst Series 2023 - Week 3 Session 5 by DianaGray10
Business Analyst Series 2023 -  Week 3 Session 5Business Analyst Series 2023 -  Week 3 Session 5
Business Analyst Series 2023 - Week 3 Session 5
DianaGray10300 views
Special_edition_innovator_2023.pdf by WillDavies22
Special_edition_innovator_2023.pdfSpecial_edition_innovator_2023.pdf
Special_edition_innovator_2023.pdf
WillDavies2218 views

Php 5.6 From the Inside Out

  • 1. PHP 5.6 From The Inside Out
  • 2. Introduction ● Ferenc Kovacs ○ DevOps guy from Budapest, Hungary ○ Infrastructure Engineer at http://www.ustream.tv/ ○ Volunteer for the PHP project since 2011 ○ Release Manager for PHP 5.6 with Julien Pauli
  • 3. History of PHP 5.6 ● 2012-11-09: First commit ● 2013-11-06: PHP-5.6 branched out ● 2014-01-23: PHP-5.6.0alpha1(rfc freeze) ● 2014-04-11: PHP-5.6.0beta1(feature freeze) ● 2014-06-19: PHP-5.6.0RC1 ● 2014-08-28: PHP-5.6.0
  • 4. Some stats about the changes Version Released Commits Authors LOC added LOC deleted 5.3.0 2009-06-30 5339 83 1575768 756904 5.4.0 2012-03-01 18779 135 3701590 2150397 5.5.0 2013-06-20 2842 113 287785 164481 5.6.0 2014-08-28 2013 107 496200 1235336 7.0 N/A 3671 90 531825 1315925
  • 5. Release Process https://wiki.php.net/rfc/releaseprocess tl;dr: ● yearly release schedule(timeboxing), 2+1 year support cycle. ● guidelines about what is allowed in a major/minor/micro version. ● resulting smaller, more predictable releases which are easier to upgrade to.
  • 6. Changes in 5.6 1. BC breaks 2. New features 3. Deprecated features
  • 7. BC breaks ● json_decode() only accepts lowercase for true/false/null to follow the JSON spec. ● Stream wrappers now verify peer certificates and host names by default when using SSL/TLS. ● GMP resources are now objects. ● Mcrypt functions now require valid keys and IVs.
  • 8. BC breaks ● unserialize() now validates the serialize format for classes implementing Serializable. ○ class Foo ■ O:3:"Foo":0:{} ○ class Foo implements Serializable ■ C:3:"Foo":4:{r:1;} ○ Can be a problem if you handcrafting the strings (PHPUnit, Doctrine) or storing those somewhere and the class definition changes(Horde).
  • 9. BC breaks ● using the @file syntax for curl file uploads are only supported if option CURLOPT_SAFE_UPLOAD is set to false. CURLFile should be used instead.
  • 10. BC breaks <?php class C { const ONE = 1; public $array = [ self::ONE => 'foo', 'bar', 'quux', ]; } count((new C)->array); // 2 on <=5.5 but 3 on >=5.6 ?>
  • 11. New features The big ones ● Constant scalar expressions ● Variadic functions ● Argument unpacking ● Power operator ● use function and use const ● phpdbg ● SSL/TLS improvements
  • 12. Constant scalar expressions <?php const ONE = 1; const TWO = ONE * 2; class C { const THREE = TWO + 1; const ONE_THIRD = ONE / self::THREE; const SENTENCE = 'The value of THREE is '.self::THREE; public function f($a = ONE + self::THREE) { return $a; } } echo (new C)->f()."n"; // 4 echo C::SENTENCE; // The value of THREE is 3 ?>
  • 13. Variadic functions <?php function f($req, $opt = null, ...$params) { // $params is an array containing the remaining arguments. printf('$req: %d; $opt: %d; number of params: %d'."n", $req, $opt, count($params)); } f(1); // $req: 1; $opt: 0; number of params: 0 f(1, 2); // $req: 1; $opt: 2; number of params: 0 f(1, 2, 3); // $req: 1; $opt: 2; number of params: 1 f(1, 2, 3, 4); // $req: 1; $opt: 2; number of params: 2 f(1, 2, 3, 4, 5); // $req: 1; $opt: 2; number of params: 3 ?>
  • 14. Argument Unpacking <?php function add($a, $b, $c) { return $a + $b + $c; } $operators = [2, 3]; echo add(1, ...$operators); // 6 ?>
  • 15. Power operator <?php printf("2 ** 3 == %dn", 2 ** 3); // 2** 3 == 8 printf("2 ** 3 ** 2 == %dn", 2 ** 3 ** 2); // 2 ** 3 ** 2 == 512 $a = 2; $a **= 3; printf("a == %dn", $a); // a == 8 ?>
  • 16. use function and use const <?php namespace NameSpace { const FOO = 42; function f() { echo __FUNCTION__."n"; } } namespace { use const NameSpaceFOO; use function NameSpacef; echo FOO."n"; // 42 f(); // NameSpacef } ?>
  • 17. phpdbg New SAPI for debugging php scripts ● really handy for debugging cli scripts or debugging without an IDE. ● no out-of-the-box solution for debugging web requests(WIP). ● no IDE integration yet(WIP). ● those familiar with gdb will probably like it.
  • 18. phpdbg features ● list source for line/function/method/class ● show info about current files/classes/functions/etc. ● print opcodes for classes/functions/current execution context, etc. ● traverse and sho information about stackframes
  • 19. phpdbg features ● show the current backtrace. ● set execution context. ● run the current execution context. ● step through the execution. ● continue the execution until the next breakpoint/watchpoint. ● continue the execution until the next breakpoint/watchpoint after the given line.
  • 20. phpdbg features ● continue the execution skipping any breakpoint/watchpoint until the current frame is finished. ● continue the execution skipping any breakpoint/watchpoint to right before we leave the current frame.
  • 21. phpdbg features ● set a conditional expression on the target where execution will break if the expression evaluates true. ● set a watchpoint on variable. ● clear breakpoints. ● clean up the execution environment(remove constant/function/class definitions).
  • 22. phpdbg features ● set the phpdbg configuration. ● source a phpdbginit script. ● register a phpdbginit function as an alias. ● shell a command. ● evaluate some code. ● quit.
  • 23. SSL/TLS improvements ● Stream wrappers now verify peer certificates and host names by default when using SSL/TLS. ● Added support SAN x509 extension matching for verifying host names in encrypted streams. ● New SSL context options for improved stream server security.
  • 24. SSL/TLS improvements ● Added support for Server Name Indication. ● Added protocol-specific encryption stream wrappers (tlsv1.0://, tlsv1.1:// and tlsv1.2://). ● Added support for managing SPKAC/SPKI.
  • 25. Other features ● __debugInfo() magic method for intercepting var_dump(); ● php://input is reusable ● Large file uploads (>2GB) are now accepted. ● The new GMP objects now support operator overloading. ● hash_equals() for constant time string comparison.
  • 26. Other features ● gost-crypto hash algo was added. ● PostgreSQL async support ○ pg_connect($dsn, PGSQL_CONNECT_ASYNC); ○ pg_connect_poll(); ○ pg_socket(); ○ pg_consume_input(); ○ pg_flush(); ● ReflectionClass:: newInstanceWithoutConstructor() can instantiate almost everything.
  • 27. Other features ● The default value for default_charset changed to UTF-8, html* iconv* and mbstring* function will use this value when no explicit encoding is set/passed. ● New fetching mode for mysqlnd, controlled via mysqlnd.fetch_data_copy. ○ Will use less memory but do more copying.
  • 28. Deprecated features ● Calls from incompatible context will now emit E_DEPRECATED instead of E_STRICT ● always_populate_raw_post_data now have a new value(-1), which completely disables the population of $HTTP_RAW_POST_DATA, setting it anything else will emit an E_DEPRECATED.
  • 29. Deprecated features ● The following settings are all deprecated in favor of default_charset: ○ iconv.input_encoding ○ iconv.output_encoding ○ iconv.internal_encoding ○ mbstring.http_input ○ mbstring.http_output ○ mbstring.internal_encoding
  • 30. Thanks for your attention! Slides will be here: http://www.slideshare.net/Tyrael If you have any questions: tyrael@php.net @Tyr43l