SlideShare a Scribd company logo
What’s new in PHP 5.5
Tom Corrigan
@thetommygnr
Melbourne PHP Users Group
May 2013
Wednesday, 22 May 13
Overview
• What’s new
• What’s gone
• What’s deprecated
• Current status of PHP 5.5
Wednesday, 22 May 13
Generators
• Syntactical sugar to avoid iterator boilerplate
• Introduce a new keyword yield
• https://wiki.php.net/rfc/generators
Wednesday, 22 May 13
Before generators
function getLinesFromFile($fileName) {
if (!$fileHandle = fopen($fileName, 'r')) {
return;
}
 
$lines = [];
while (false !== $line = fgets($fileHandle)) {
$lines[] = $line;
}
 
fclose($fileHandle);
 
return $lines;
}
 
$lines = getLinesFromFile($fileName);
foreach ($lines as $line) {
// do something with $line
}
Wednesday, 22 May 13
Generator in action
function getLinesFromFile($fileName) {
if (!$fileHandle = fopen($fileName, 'r')) {
return;
}
 
while (false !== $line = fgets($fileHandle)) {
yield $line;
}
 
fclose($fileHandle);
}
 
$lines = getLinesFromFile($fileName);
foreach ($lines as $line) {
// do something with $line
}
Wednesday, 22 May 13
Generator free approach
function doShit($filename){
if (!$fileHandle = fopen($fileName, 'r')) {
return;
}
 
while (false !== $line = fgets($fileHandle)) {
// do something with $line
}
 
fclose($fileHandle);
}
Wednesday, 22 May 13
Generators - my opinion
• Few use cases
• Every example I found demonstrated the functionality rather than its
utility
• More readable alternatives
Wednesday, 22 May 13
Finally
• New addition to try...catch blocks
• Code within a finally block will always be executed. Always!
• Useful for closing DB connections, file handles etc
• https://wiki.php.net/rfc/finally
Wednesday, 22 May 13
The problem:
$db = mysqli_connect();
try {
call_some_function($db); //function may throw exceptions which we can ‘t
handle
} catch (Exception $e) {
mysqli_close($db);
throw $e;
}
mysql_close($db);
Wednesday, 22 May 13
Finally: a solution
$db = mysqli_connect();
try {
call_some_function($db);//function may throw exceptions which we can ‘t
handle
} finally {
mysqli_close($db);
}
Wednesday, 22 May 13
Finally block is always executed
try {
return 2;
} finally {
echo "this will be calledn";
}
//this will never be called
echo "you can not see me";
this will be called
//return int(2)
Wednesday, 22 May 13
Opcache
• Zend Optimizer+ has been open sourced and renamed Opcache
• Included by default in PHP 5.5+
• This is a big win, it’s the fastest opcode cache for PHP, between
5%-20% faster than APC
• https://wiki.php.net/rfc/optimizerplus
Wednesday, 22 May 13
What about APC?
• No current plans to support PHP > 5.4
• Does it matter?
• Was always behind new PHP releases by months
• Opcache is faster
• Opcaches ships with PHP 5.5+
Wednesday, 22 May 13
APCu
• APC without the bytecode cache (userland caching only)
• PHP API maintains BC with APC
• https://github.com/krakjoe/apcu
Wednesday, 22 May 13
DateTimeImmutable
• DateTime
$dt = new DateTime(‘2013-05-21’);
$dt2 = $dt->modify(‘+1 day’);
echo $dt->format(‘Y-m-d’); //2013-5-22
echo $dt2->format(‘Y-m-d’); //2013-5-22
• DateTimeImmutable
$dt = new DateTimeImmutable(‘2013-05-21’);
$dt2 = $dt->modify(‘+1 day’);
echo $dt->format(‘Y-m-d’); //2013-5-21
echo $dt2->format(‘Y-m-d’); //2013-5-22
• Warning: Extends DateTime, type hints won’t save you
Wednesday, 22 May 13
Constant array and string
dereferencing
You can now do this:
echo [“one”, “two”, “three”][1];
=> “two”
And this:
echo “onetwothree”[1];
=> “n”
Wednesday, 22 May 13
list() inside foreach
$talks = [
[
"speaker" => "Tom Corrigan",
"talk" => "What’s new in PHP 5.5",
],
[
"speaker" => "Rick Measham",
"talk" => "Hacker tips for getting hired",
],
];
foreach ($talks as list($speaker, $talk){
echo $speaker. " on " . $talk . PHP_EOL;
}
// Tom Corrigan on What’s new in PHP 5.5
// Rick Measham on Hacker tips for getting hired
•https://wiki.php.net/rfc/foreachlist
Wednesday, 22 May 13
array_column()
$talks = [
[
"speaker" => "Tom Corrigan",
"talk" => "What’s new in PHP 5.5",
],
[
"speaker" => "Rick Measham",
"talk" => "Hacker tips for getting hired",
],
];
$speakers = array_column($talks, "speaker");
//array
[0] Tom Corrigan
[1] Rick Measham
• https://wiki.php.net/rfc/array_column
Wednesday, 22 May 13
Password hash
• Colby did a talk last month
• Use it today in PHP 5.3.7+ https://github.com/ircmaxell/
password_compat
Wednesday, 22 May 13
Tons of new stuff in ext/intl
• Didn’t get time to cover this one, sorry!
• See: http://www.php.net/manual/en/migration55.classes.php
Wednesday, 22 May 13
Removed/changed
• No Windows XP or 2003 support
• Case insensitivity no longer locale specific
• Logo functions removed: php_logo_guid(), php_egg_logo_guid() etc
• Changes to pack() and unpack() BC BREAK
• http://www.php.net/manual/en/migration55.incompatible.php
Wednesday, 22 May 13
Deprecated
• ext/mysql !!!!
• preg_replace() /e modifier, use preg_replace_callback() (good!)
• IntlDateFormatter::setTimeZoneID() and datefmt_set_timezone_id()
• some mcrypt functions
• http://www.php.net/manual/en/migration55.deprecated.php
Wednesday, 22 May 13
Current status
• First Release Candidate: 9 May
• Second RC due out on 23rd May
• Expected stable release soon
Wednesday, 22 May 13
Questions?
Wednesday, 22 May 13

More Related Content

What's hot

PHP7 Presentation
PHP7 PresentationPHP7 Presentation
PHP7 Presentation
David Sanchez
 
Webrtc mojo
Webrtc mojoWebrtc mojo
Webrtc mojo
bpmedley
 
Php in 2013 (Web-5 2013 conference)
Php in 2013 (Web-5 2013 conference)Php in 2013 (Web-5 2013 conference)
Php in 2013 (Web-5 2013 conference)
julien pauli
 
Yapcasia2011 - Hello Embed Perl
Yapcasia2011 - Hello Embed PerlYapcasia2011 - Hello Embed Perl
Yapcasia2011 - Hello Embed Perl
Hideaki Ohno
 
Melhorando sua API com DSLs
Melhorando sua API com DSLsMelhorando sua API com DSLs
Melhorando sua API com DSLs
Augusto Pascutti
 
Php hacku
Php hackuPhp hacku
PHP 5.3 And PHP 6 A Look Ahead
PHP 5.3 And PHP 6 A Look AheadPHP 5.3 And PHP 6 A Look Ahead
PHP 5.3 And PHP 6 A Look Ahead
thinkphp
 
Smolder @Silex
Smolder @SilexSmolder @Silex
Smolder @Silex
Jeen Lee
 
Kansai.pm 10周年記念 Plack/PSGI 入門
Kansai.pm 10周年記念 Plack/PSGI 入門Kansai.pm 10周年記念 Plack/PSGI 入門
Kansai.pm 10周年記念 Plack/PSGI 入門
lestrrat
 
GettingStartedWithPHP
GettingStartedWithPHPGettingStartedWithPHP
GettingStartedWithPHP
Nat Weerawan
 
Cli the other SAPI confoo11
Cli the other SAPI confoo11Cli the other SAPI confoo11
Cli the other SAPI confoo11
Combell NV
 
CLI, the other SAPI phpnw11
CLI, the other SAPI phpnw11CLI, the other SAPI phpnw11
CLI, the other SAPI phpnw11
Combell NV
 
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
Mark Baker
 
関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい
Hisateru Tanaka
 
AnyMQ, Hippie, and the real-time web
AnyMQ, Hippie, and the real-time webAnyMQ, Hippie, and the real-time web
AnyMQ, Hippie, and the real-time web
clkao
 
Asynchronous I/O in PHP
Asynchronous I/O in PHPAsynchronous I/O in PHP
Asynchronous I/O in PHP
Thomas Weinert
 
Php 7 hhvm and co
Php 7 hhvm and coPhp 7 hhvm and co
Php 7 hhvm and co
Pierre Joye
 
Perl web frameworks
Perl web frameworksPerl web frameworks
Perl web frameworks
diego_k
 
ekb.py - Python VS ...
ekb.py - Python VS ...ekb.py - Python VS ...
ekb.py - Python VS ...
it-people
 
ZeroMQ Is The Answer
ZeroMQ Is The AnswerZeroMQ Is The Answer
ZeroMQ Is The Answer
Ian Barber
 

What's hot (20)

PHP7 Presentation
PHP7 PresentationPHP7 Presentation
PHP7 Presentation
 
Webrtc mojo
Webrtc mojoWebrtc mojo
Webrtc mojo
 
Php in 2013 (Web-5 2013 conference)
Php in 2013 (Web-5 2013 conference)Php in 2013 (Web-5 2013 conference)
Php in 2013 (Web-5 2013 conference)
 
Yapcasia2011 - Hello Embed Perl
Yapcasia2011 - Hello Embed PerlYapcasia2011 - Hello Embed Perl
Yapcasia2011 - Hello Embed Perl
 
Melhorando sua API com DSLs
Melhorando sua API com DSLsMelhorando sua API com DSLs
Melhorando sua API com DSLs
 
Php hacku
Php hackuPhp hacku
Php hacku
 
PHP 5.3 And PHP 6 A Look Ahead
PHP 5.3 And PHP 6 A Look AheadPHP 5.3 And PHP 6 A Look Ahead
PHP 5.3 And PHP 6 A Look Ahead
 
Smolder @Silex
Smolder @SilexSmolder @Silex
Smolder @Silex
 
Kansai.pm 10周年記念 Plack/PSGI 入門
Kansai.pm 10周年記念 Plack/PSGI 入門Kansai.pm 10周年記念 Plack/PSGI 入門
Kansai.pm 10周年記念 Plack/PSGI 入門
 
GettingStartedWithPHP
GettingStartedWithPHPGettingStartedWithPHP
GettingStartedWithPHP
 
Cli the other SAPI confoo11
Cli the other SAPI confoo11Cli the other SAPI confoo11
Cli the other SAPI confoo11
 
CLI, the other SAPI phpnw11
CLI, the other SAPI phpnw11CLI, the other SAPI phpnw11
CLI, the other SAPI phpnw11
 
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
 
関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい
 
AnyMQ, Hippie, and the real-time web
AnyMQ, Hippie, and the real-time webAnyMQ, Hippie, and the real-time web
AnyMQ, Hippie, and the real-time web
 
Asynchronous I/O in PHP
Asynchronous I/O in PHPAsynchronous I/O in PHP
Asynchronous I/O in PHP
 
Php 7 hhvm and co
Php 7 hhvm and coPhp 7 hhvm and co
Php 7 hhvm and co
 
Perl web frameworks
Perl web frameworksPerl web frameworks
Perl web frameworks
 
ekb.py - Python VS ...
ekb.py - Python VS ...ekb.py - Python VS ...
ekb.py - Python VS ...
 
ZeroMQ Is The Answer
ZeroMQ Is The AnswerZeroMQ Is The Answer
ZeroMQ Is The Answer
 

Viewers also liked

Impl installation manual
Impl installation manualImpl installation manual
Impl installation manual
Alkis Vazacopoulos
 
Master project vol i
Master project vol iMaster project vol i
Master project vol i
Sankha Pallab Chakrabarti
 
Question 1 for media evaluation pow
Question 1 for media evaluation powQuestion 1 for media evaluation pow
Question 1 for media evaluation pow
Maddie Bonneau
 
Whetstone u09a1.irregular verbs
Whetstone u09a1.irregular verbsWhetstone u09a1.irregular verbs
Whetstone u09a1.irregular verbs
jillwhetstone
 
Rebeca salas y hilary jimenes
Rebeca salas y hilary jimenesRebeca salas y hilary jimenes
Rebeca salas y hilary jimenes
Rebeca Salas
 
ДНЗ № 189 ( круглый стол)
ДНЗ № 189 ( круглый стол)ДНЗ № 189 ( круглый стол)
ДНЗ № 189 ( круглый стол)
olchik_p
 
James e cook jr!
James e cook jr!James e cook jr!
James e cook jr!
Christa Sallie
 
Springley - Water Case Study
Springley - Water Case StudySpringley - Water Case Study
Springley - Water Case Study
Fakhir Rehman
 
Chapter07
Chapter07Chapter07
Chapter07
Mohini Dhiman
 
Презентация Васильківської ЗОШ І-ІІІ ст№8 "Військове містечко11""
Презентация Васильківської ЗОШ І-ІІІ ст№8 "Військове містечко11""Презентация Васильківської ЗОШ І-ІІІ ст№8 "Військове містечко11""
Презентация Васильківської ЗОШ І-ІІІ ст№8 "Військове містечко11""
08600 Vasilkov
 
My Certificates - Volume 1
My Certificates - Volume 1My Certificates - Volume 1
My Certificates - Volume 1
Tony Campanale
 
Word by word fatima and laura
Word by word fatima and lauraWord by word fatima and laura
Word by word fatima and laura
eso1113enricborras
 
физкультурно оздоровительный блок
физкультурно оздоровительный блокфизкультурно оздоровительный блок
физкультурно оздоровительный блок
AkuJIa
 
You can take it with you: Rollover planning
You can take it with you: Rollover planningYou can take it with you: Rollover planning
You can take it with you: Rollover planning
Jayme Lacour
 
Parallel Computing for Econometricians with Amazon Web Services
Parallel Computing for Econometricians with Amazon Web ServicesParallel Computing for Econometricians with Amazon Web Services
Parallel Computing for Econometricians with Amazon Web Services
stephenjbarr
 
Celebramos os maios
Celebramos os maios Celebramos os maios
Celebramos os maios
María Concepción Fernández
 
Report of the science society
Report of the science societyReport of the science society
Report of the science society
hanisah67
 
Презентація команди Васильківської ЗОШ І-ІІІ ступенів №2
Презентація команди Васильківської ЗОШ І-ІІІ ступенів №2Презентація команди Васильківської ЗОШ І-ІІІ ступенів №2
Презентація команди Васильківської ЗОШ І-ІІІ ступенів №2
08600 Vasilkov
 
Task 1
Task 1Task 1
Task 1
Emma Heald
 
Big data網站分析─google analytics學習筆記 (情報快訊與轉換功能)
Big data網站分析─google analytics學習筆記 (情報快訊與轉換功能) Big data網站分析─google analytics學習筆記 (情報快訊與轉換功能)
Big data網站分析─google analytics學習筆記 (情報快訊與轉換功能)
Anna Su
 

Viewers also liked (20)

Impl installation manual
Impl installation manualImpl installation manual
Impl installation manual
 
Master project vol i
Master project vol iMaster project vol i
Master project vol i
 
Question 1 for media evaluation pow
Question 1 for media evaluation powQuestion 1 for media evaluation pow
Question 1 for media evaluation pow
 
Whetstone u09a1.irregular verbs
Whetstone u09a1.irregular verbsWhetstone u09a1.irregular verbs
Whetstone u09a1.irregular verbs
 
Rebeca salas y hilary jimenes
Rebeca salas y hilary jimenesRebeca salas y hilary jimenes
Rebeca salas y hilary jimenes
 
ДНЗ № 189 ( круглый стол)
ДНЗ № 189 ( круглый стол)ДНЗ № 189 ( круглый стол)
ДНЗ № 189 ( круглый стол)
 
James e cook jr!
James e cook jr!James e cook jr!
James e cook jr!
 
Springley - Water Case Study
Springley - Water Case StudySpringley - Water Case Study
Springley - Water Case Study
 
Chapter07
Chapter07Chapter07
Chapter07
 
Презентация Васильківської ЗОШ І-ІІІ ст№8 "Військове містечко11""
Презентация Васильківської ЗОШ І-ІІІ ст№8 "Військове містечко11""Презентация Васильківської ЗОШ І-ІІІ ст№8 "Військове містечко11""
Презентация Васильківської ЗОШ І-ІІІ ст№8 "Військове містечко11""
 
My Certificates - Volume 1
My Certificates - Volume 1My Certificates - Volume 1
My Certificates - Volume 1
 
Word by word fatima and laura
Word by word fatima and lauraWord by word fatima and laura
Word by word fatima and laura
 
физкультурно оздоровительный блок
физкультурно оздоровительный блокфизкультурно оздоровительный блок
физкультурно оздоровительный блок
 
You can take it with you: Rollover planning
You can take it with you: Rollover planningYou can take it with you: Rollover planning
You can take it with you: Rollover planning
 
Parallel Computing for Econometricians with Amazon Web Services
Parallel Computing for Econometricians with Amazon Web ServicesParallel Computing for Econometricians with Amazon Web Services
Parallel Computing for Econometricians with Amazon Web Services
 
Celebramos os maios
Celebramos os maios Celebramos os maios
Celebramos os maios
 
Report of the science society
Report of the science societyReport of the science society
Report of the science society
 
Презентація команди Васильківської ЗОШ І-ІІІ ступенів №2
Презентація команди Васильківської ЗОШ І-ІІІ ступенів №2Презентація команди Васильківської ЗОШ І-ІІІ ступенів №2
Презентація команди Васильківської ЗОШ І-ІІІ ступенів №2
 
Task 1
Task 1Task 1
Task 1
 
Big data網站分析─google analytics學習筆記 (情報快訊與轉換功能)
Big data網站分析─google analytics學習筆記 (情報快訊與轉換功能) Big data網站分析─google analytics學習筆記 (情報快訊與轉換功能)
Big data網站分析─google analytics學習筆記 (情報快訊與轉換功能)
 

Similar to What's new in PHP 5.5

The why and how of moving to php 5.4
The why and how of moving to php 5.4The why and how of moving to php 5.4
The why and how of moving to php 5.4
Wim Godden
 
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
Wim Godden
 
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
Wim Godden
 
PHP Streams
PHP StreamsPHP Streams
PHP Streams
G Woo
 
ZendCon 08 php 5.3
ZendCon 08 php 5.3ZendCon 08 php 5.3
ZendCon 08 php 5.3
webhostingguy
 
Debugging: Rules & Tools
Debugging: Rules & ToolsDebugging: Rules & Tools
Debugging: Rules & Tools
Ian Barber
 
PHP 5.3 Overview
PHP 5.3 OverviewPHP 5.3 Overview
PHP 5.3 Overview
jsmith92
 
What's new with PHP7
What's new with PHP7What's new with PHP7
What's new with PHP7
SWIFTotter Solutions
 
Debugging: Rules And Tools - PHPTek 11 Version
Debugging: Rules And Tools - PHPTek 11 VersionDebugging: Rules And Tools - PHPTek 11 Version
Debugging: Rules And Tools - PHPTek 11 Version
Ian Barber
 
The new features of PHP 7 - Enrico Zimuel - Codemotion Milan 2016
The new features of PHP 7 - Enrico Zimuel - Codemotion Milan 2016The new features of PHP 7 - Enrico Zimuel - Codemotion Milan 2016
The new features of PHP 7 - Enrico Zimuel - Codemotion Milan 2016
Codemotion
 
Php7 HHVM and co
Php7 HHVM and coPhp7 HHVM and co
Php7 HHVM and co
weltling
 
2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Heroku2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Heroku
ronnywang_tw
 
Php basic for vit university
Php basic for vit universityPhp basic for vit university
Php basic for vit university
Mandakini Kumari
 
Current state-of-php
Current state-of-phpCurrent state-of-php
Current state-of-php
Richard McIntyre
 
PHP 5 Sucks. PHP 5 Rocks.
PHP 5 Sucks. PHP 5 Rocks.PHP 5 Sucks. PHP 5 Rocks.
PHP 5 Sucks. PHP 5 Rocks.
Adam Trachtenberg
 
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
Wim Godden
 
New in php 7
New in php 7New in php 7
New in php 7
Vic Metcalfe
 
Php7 hhvm and co
Php7 hhvm and coPhp7 hhvm and co
Php7 hhvm and co
Pierre Joye
 
50 shades of PHP
50 shades of PHP50 shades of PHP
50 shades of PHP
Maksym Hopei
 
Time tested php with libtimemachine
Time tested php with libtimemachineTime tested php with libtimemachine
Time tested php with libtimemachine
Nick Galbreath
 

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

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
 
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
 
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
 
PHP Streams
PHP StreamsPHP Streams
PHP Streams
 
ZendCon 08 php 5.3
ZendCon 08 php 5.3ZendCon 08 php 5.3
ZendCon 08 php 5.3
 
Debugging: Rules & Tools
Debugging: Rules & ToolsDebugging: Rules & Tools
Debugging: Rules & Tools
 
PHP 5.3 Overview
PHP 5.3 OverviewPHP 5.3 Overview
PHP 5.3 Overview
 
What's new with PHP7
What's new with PHP7What's new with PHP7
What's new with PHP7
 
Debugging: Rules And Tools - PHPTek 11 Version
Debugging: Rules And Tools - PHPTek 11 VersionDebugging: Rules And Tools - PHPTek 11 Version
Debugging: Rules And Tools - PHPTek 11 Version
 
The new features of PHP 7 - Enrico Zimuel - Codemotion Milan 2016
The new features of PHP 7 - Enrico Zimuel - Codemotion Milan 2016The new features of PHP 7 - Enrico Zimuel - Codemotion Milan 2016
The new features of PHP 7 - Enrico Zimuel - Codemotion Milan 2016
 
Php7 HHVM and co
Php7 HHVM and coPhp7 HHVM and co
Php7 HHVM and co
 
2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Heroku2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Heroku
 
Php basic for vit university
Php basic for vit universityPhp basic for vit university
Php basic for vit university
 
Current state-of-php
Current state-of-phpCurrent state-of-php
Current state-of-php
 
PHP 5 Sucks. PHP 5 Rocks.
PHP 5 Sucks. PHP 5 Rocks.PHP 5 Sucks. PHP 5 Rocks.
PHP 5 Sucks. PHP 5 Rocks.
 
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
 
New in php 7
New in php 7New in php 7
New in php 7
 
Php7 hhvm and co
Php7 hhvm and coPhp7 hhvm and co
Php7 hhvm and co
 
50 shades of PHP
50 shades of PHP50 shades of PHP
50 shades of PHP
 
Time tested php with libtimemachine
Time tested php with libtimemachineTime tested php with libtimemachine
Time tested php with libtimemachine
 

Recently uploaded

Russian Girls Call Navi Mumbai 🎈🔥9920725232 🔥💋🎈 Provide Best And Top Girl Ser...
Russian Girls Call Navi Mumbai 🎈🔥9920725232 🔥💋🎈 Provide Best And Top Girl Ser...Russian Girls Call Navi Mumbai 🎈🔥9920725232 🔥💋🎈 Provide Best And Top Girl Ser...
Russian Girls Call Navi Mumbai 🎈🔥9920725232 🔥💋🎈 Provide Best And Top Girl Ser...
bellared2
 
July Patch Tuesday
July Patch TuesdayJuly Patch Tuesday
July Patch Tuesday
Ivanti
 
EuroPython 2024 - Streamlining Testing in a Large Python Codebase
EuroPython 2024 - Streamlining Testing in a Large Python CodebaseEuroPython 2024 - Streamlining Testing in a Large Python Codebase
EuroPython 2024 - Streamlining Testing in a Large Python Codebase
Jimmy Lai
 
"Mastering Graphic Design: Essential Tips and Tricks for Beginners and Profes...
"Mastering Graphic Design: Essential Tips and Tricks for Beginners and Profes..."Mastering Graphic Design: Essential Tips and Tricks for Beginners and Profes...
"Mastering Graphic Design: Essential Tips and Tricks for Beginners and Profes...
Anant Gupta
 
Girls Call Churchgate 9910780858 Provide Best And Top Girl Service And No1 in...
Girls Call Churchgate 9910780858 Provide Best And Top Girl Service And No1 in...Girls Call Churchgate 9910780858 Provide Best And Top Girl Service And No1 in...
Girls Call Churchgate 9910780858 Provide Best And Top Girl Service And No1 in...
maigasapphire
 
Three New Criminal Laws in India 1 July 2024
Three New Criminal Laws in India 1 July 2024Three New Criminal Laws in India 1 July 2024
Three New Criminal Laws in India 1 July 2024
aakash malhotra
 
BT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdf
BT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdfBT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdf
BT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdf
Neo4j
 
Vulnerability Management: A Comprehensive Overview
Vulnerability Management: A Comprehensive OverviewVulnerability Management: A Comprehensive Overview
Vulnerability Management: A Comprehensive Overview
Steven Carlson
 
(CISOPlatform Summit & SACON 2024) Gen AI & Deepfake In Overall Security.pdf
(CISOPlatform Summit & SACON 2024) Gen AI & Deepfake In Overall Security.pdf(CISOPlatform Summit & SACON 2024) Gen AI & Deepfake In Overall Security.pdf
(CISOPlatform Summit & SACON 2024) Gen AI & Deepfake In Overall Security.pdf
Priyanka Aash
 
Google I/O Extended Harare Merged Slides
Google I/O Extended Harare Merged SlidesGoogle I/O Extended Harare Merged Slides
Google I/O Extended Harare Merged Slides
Google Developer Group - Harare
 
Best Practices for Effectively Running dbt in Airflow.pdf
Best Practices for Effectively Running dbt in Airflow.pdfBest Practices for Effectively Running dbt in Airflow.pdf
Best Practices for Effectively Running dbt in Airflow.pdf
Tatiana Al-Chueyr
 
The importance of Quality Assurance for ICT Standardization
The importance of Quality Assurance for ICT StandardizationThe importance of Quality Assurance for ICT Standardization
The importance of Quality Assurance for ICT Standardization
Axel Rennoch
 
Semantic-Aware Code Model: Elevating the Future of Software Development
Semantic-Aware Code Model: Elevating the Future of Software DevelopmentSemantic-Aware Code Model: Elevating the Future of Software Development
Semantic-Aware Code Model: Elevating the Future of Software Development
Baishakhi Ray
 
How to Build a Profitable IoT Product.pptx
How to Build a Profitable IoT Product.pptxHow to Build a Profitable IoT Product.pptx
How to Build a Profitable IoT Product.pptx
Adam Dunkels
 
Using LLM Agents with Llama 3, LangGraph and Milvus
Using LLM Agents with Llama 3, LangGraph and MilvusUsing LLM Agents with Llama 3, LangGraph and Milvus
Using LLM Agents with Llama 3, LangGraph and Milvus
Zilliz
 
Introduction-to-the-IAM-Platform-Implementation-Plan.pptx
Introduction-to-the-IAM-Platform-Implementation-Plan.pptxIntroduction-to-the-IAM-Platform-Implementation-Plan.pptx
Introduction-to-the-IAM-Platform-Implementation-Plan.pptx
313mohammedarshad
 
Mastering OnlyFans Clone App Development: Key Strategies for Success
Mastering OnlyFans Clone App Development: Key Strategies for SuccessMastering OnlyFans Clone App Development: Key Strategies for Success
Mastering OnlyFans Clone App Development: Key Strategies for Success
David Wilson
 
IPLOOK Remote-Sensing Satellite Solution
IPLOOK Remote-Sensing Satellite SolutionIPLOOK Remote-Sensing Satellite Solution
IPLOOK Remote-Sensing Satellite Solution
IPLOOK Networks
 
(CISOPlatform Summit & SACON 2024) Digital Personal Data Protection Act.pdf
(CISOPlatform Summit & SACON 2024) Digital Personal Data Protection Act.pdf(CISOPlatform Summit & SACON 2024) Digital Personal Data Protection Act.pdf
(CISOPlatform Summit & SACON 2024) Digital Personal Data Protection Act.pdf
Priyanka Aash
 
(CISOPlatform Summit & SACON 2024) Cyber Insurance & Risk Quantification.pdf
(CISOPlatform Summit & SACON 2024) Cyber Insurance & Risk Quantification.pdf(CISOPlatform Summit & SACON 2024) Cyber Insurance & Risk Quantification.pdf
(CISOPlatform Summit & SACON 2024) Cyber Insurance & Risk Quantification.pdf
Priyanka Aash
 

Recently uploaded (20)

Russian Girls Call Navi Mumbai 🎈🔥9920725232 🔥💋🎈 Provide Best And Top Girl Ser...
Russian Girls Call Navi Mumbai 🎈🔥9920725232 🔥💋🎈 Provide Best And Top Girl Ser...Russian Girls Call Navi Mumbai 🎈🔥9920725232 🔥💋🎈 Provide Best And Top Girl Ser...
Russian Girls Call Navi Mumbai 🎈🔥9920725232 🔥💋🎈 Provide Best And Top Girl Ser...
 
July Patch Tuesday
July Patch TuesdayJuly Patch Tuesday
July Patch Tuesday
 
EuroPython 2024 - Streamlining Testing in a Large Python Codebase
EuroPython 2024 - Streamlining Testing in a Large Python CodebaseEuroPython 2024 - Streamlining Testing in a Large Python Codebase
EuroPython 2024 - Streamlining Testing in a Large Python Codebase
 
"Mastering Graphic Design: Essential Tips and Tricks for Beginners and Profes...
"Mastering Graphic Design: Essential Tips and Tricks for Beginners and Profes..."Mastering Graphic Design: Essential Tips and Tricks for Beginners and Profes...
"Mastering Graphic Design: Essential Tips and Tricks for Beginners and Profes...
 
Girls Call Churchgate 9910780858 Provide Best And Top Girl Service And No1 in...
Girls Call Churchgate 9910780858 Provide Best And Top Girl Service And No1 in...Girls Call Churchgate 9910780858 Provide Best And Top Girl Service And No1 in...
Girls Call Churchgate 9910780858 Provide Best And Top Girl Service And No1 in...
 
Three New Criminal Laws in India 1 July 2024
Three New Criminal Laws in India 1 July 2024Three New Criminal Laws in India 1 July 2024
Three New Criminal Laws in India 1 July 2024
 
BT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdf
BT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdfBT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdf
BT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdf
 
Vulnerability Management: A Comprehensive Overview
Vulnerability Management: A Comprehensive OverviewVulnerability Management: A Comprehensive Overview
Vulnerability Management: A Comprehensive Overview
 
(CISOPlatform Summit & SACON 2024) Gen AI & Deepfake In Overall Security.pdf
(CISOPlatform Summit & SACON 2024) Gen AI & Deepfake In Overall Security.pdf(CISOPlatform Summit & SACON 2024) Gen AI & Deepfake In Overall Security.pdf
(CISOPlatform Summit & SACON 2024) Gen AI & Deepfake In Overall Security.pdf
 
Google I/O Extended Harare Merged Slides
Google I/O Extended Harare Merged SlidesGoogle I/O Extended Harare Merged Slides
Google I/O Extended Harare Merged Slides
 
Best Practices for Effectively Running dbt in Airflow.pdf
Best Practices for Effectively Running dbt in Airflow.pdfBest Practices for Effectively Running dbt in Airflow.pdf
Best Practices for Effectively Running dbt in Airflow.pdf
 
The importance of Quality Assurance for ICT Standardization
The importance of Quality Assurance for ICT StandardizationThe importance of Quality Assurance for ICT Standardization
The importance of Quality Assurance for ICT Standardization
 
Semantic-Aware Code Model: Elevating the Future of Software Development
Semantic-Aware Code Model: Elevating the Future of Software DevelopmentSemantic-Aware Code Model: Elevating the Future of Software Development
Semantic-Aware Code Model: Elevating the Future of Software Development
 
How to Build a Profitable IoT Product.pptx
How to Build a Profitable IoT Product.pptxHow to Build a Profitable IoT Product.pptx
How to Build a Profitable IoT Product.pptx
 
Using LLM Agents with Llama 3, LangGraph and Milvus
Using LLM Agents with Llama 3, LangGraph and MilvusUsing LLM Agents with Llama 3, LangGraph and Milvus
Using LLM Agents with Llama 3, LangGraph and Milvus
 
Introduction-to-the-IAM-Platform-Implementation-Plan.pptx
Introduction-to-the-IAM-Platform-Implementation-Plan.pptxIntroduction-to-the-IAM-Platform-Implementation-Plan.pptx
Introduction-to-the-IAM-Platform-Implementation-Plan.pptx
 
Mastering OnlyFans Clone App Development: Key Strategies for Success
Mastering OnlyFans Clone App Development: Key Strategies for SuccessMastering OnlyFans Clone App Development: Key Strategies for Success
Mastering OnlyFans Clone App Development: Key Strategies for Success
 
IPLOOK Remote-Sensing Satellite Solution
IPLOOK Remote-Sensing Satellite SolutionIPLOOK Remote-Sensing Satellite Solution
IPLOOK Remote-Sensing Satellite Solution
 
(CISOPlatform Summit & SACON 2024) Digital Personal Data Protection Act.pdf
(CISOPlatform Summit & SACON 2024) Digital Personal Data Protection Act.pdf(CISOPlatform Summit & SACON 2024) Digital Personal Data Protection Act.pdf
(CISOPlatform Summit & SACON 2024) Digital Personal Data Protection Act.pdf
 
(CISOPlatform Summit & SACON 2024) Cyber Insurance & Risk Quantification.pdf
(CISOPlatform Summit & SACON 2024) Cyber Insurance & Risk Quantification.pdf(CISOPlatform Summit & SACON 2024) Cyber Insurance & Risk Quantification.pdf
(CISOPlatform Summit & SACON 2024) Cyber Insurance & Risk Quantification.pdf
 

What's new in PHP 5.5

  • 1. What’s new in PHP 5.5 Tom Corrigan @thetommygnr Melbourne PHP Users Group May 2013 Wednesday, 22 May 13
  • 2. Overview • What’s new • What’s gone • What’s deprecated • Current status of PHP 5.5 Wednesday, 22 May 13
  • 3. Generators • Syntactical sugar to avoid iterator boilerplate • Introduce a new keyword yield • https://wiki.php.net/rfc/generators Wednesday, 22 May 13
  • 4. Before generators function getLinesFromFile($fileName) { if (!$fileHandle = fopen($fileName, 'r')) { return; }   $lines = []; while (false !== $line = fgets($fileHandle)) { $lines[] = $line; }   fclose($fileHandle);   return $lines; }   $lines = getLinesFromFile($fileName); foreach ($lines as $line) { // do something with $line } Wednesday, 22 May 13
  • 5. Generator in action function getLinesFromFile($fileName) { if (!$fileHandle = fopen($fileName, 'r')) { return; }   while (false !== $line = fgets($fileHandle)) { yield $line; }   fclose($fileHandle); }   $lines = getLinesFromFile($fileName); foreach ($lines as $line) { // do something with $line } Wednesday, 22 May 13
  • 6. Generator free approach function doShit($filename){ if (!$fileHandle = fopen($fileName, 'r')) { return; }   while (false !== $line = fgets($fileHandle)) { // do something with $line }   fclose($fileHandle); } Wednesday, 22 May 13
  • 7. Generators - my opinion • Few use cases • Every example I found demonstrated the functionality rather than its utility • More readable alternatives Wednesday, 22 May 13
  • 8. Finally • New addition to try...catch blocks • Code within a finally block will always be executed. Always! • Useful for closing DB connections, file handles etc • https://wiki.php.net/rfc/finally Wednesday, 22 May 13
  • 9. The problem: $db = mysqli_connect(); try { call_some_function($db); //function may throw exceptions which we can ‘t handle } catch (Exception $e) { mysqli_close($db); throw $e; } mysql_close($db); Wednesday, 22 May 13
  • 10. Finally: a solution $db = mysqli_connect(); try { call_some_function($db);//function may throw exceptions which we can ‘t handle } finally { mysqli_close($db); } Wednesday, 22 May 13
  • 11. Finally block is always executed try { return 2; } finally { echo "this will be calledn"; } //this will never be called echo "you can not see me"; this will be called //return int(2) Wednesday, 22 May 13
  • 12. Opcache • Zend Optimizer+ has been open sourced and renamed Opcache • Included by default in PHP 5.5+ • This is a big win, it’s the fastest opcode cache for PHP, between 5%-20% faster than APC • https://wiki.php.net/rfc/optimizerplus Wednesday, 22 May 13
  • 13. What about APC? • No current plans to support PHP > 5.4 • Does it matter? • Was always behind new PHP releases by months • Opcache is faster • Opcaches ships with PHP 5.5+ Wednesday, 22 May 13
  • 14. APCu • APC without the bytecode cache (userland caching only) • PHP API maintains BC with APC • https://github.com/krakjoe/apcu Wednesday, 22 May 13
  • 15. DateTimeImmutable • DateTime $dt = new DateTime(‘2013-05-21’); $dt2 = $dt->modify(‘+1 day’); echo $dt->format(‘Y-m-d’); //2013-5-22 echo $dt2->format(‘Y-m-d’); //2013-5-22 • DateTimeImmutable $dt = new DateTimeImmutable(‘2013-05-21’); $dt2 = $dt->modify(‘+1 day’); echo $dt->format(‘Y-m-d’); //2013-5-21 echo $dt2->format(‘Y-m-d’); //2013-5-22 • Warning: Extends DateTime, type hints won’t save you Wednesday, 22 May 13
  • 16. Constant array and string dereferencing You can now do this: echo [“one”, “two”, “three”][1]; => “two” And this: echo “onetwothree”[1]; => “n” Wednesday, 22 May 13
  • 17. list() inside foreach $talks = [ [ "speaker" => "Tom Corrigan", "talk" => "What’s new in PHP 5.5", ], [ "speaker" => "Rick Measham", "talk" => "Hacker tips for getting hired", ], ]; foreach ($talks as list($speaker, $talk){ echo $speaker. " on " . $talk . PHP_EOL; } // Tom Corrigan on What’s new in PHP 5.5 // Rick Measham on Hacker tips for getting hired •https://wiki.php.net/rfc/foreachlist Wednesday, 22 May 13
  • 18. array_column() $talks = [ [ "speaker" => "Tom Corrigan", "talk" => "What’s new in PHP 5.5", ], [ "speaker" => "Rick Measham", "talk" => "Hacker tips for getting hired", ], ]; $speakers = array_column($talks, "speaker"); //array [0] Tom Corrigan [1] Rick Measham • https://wiki.php.net/rfc/array_column Wednesday, 22 May 13
  • 19. Password hash • Colby did a talk last month • Use it today in PHP 5.3.7+ https://github.com/ircmaxell/ password_compat Wednesday, 22 May 13
  • 20. Tons of new stuff in ext/intl • Didn’t get time to cover this one, sorry! • See: http://www.php.net/manual/en/migration55.classes.php Wednesday, 22 May 13
  • 21. Removed/changed • No Windows XP or 2003 support • Case insensitivity no longer locale specific • Logo functions removed: php_logo_guid(), php_egg_logo_guid() etc • Changes to pack() and unpack() BC BREAK • http://www.php.net/manual/en/migration55.incompatible.php Wednesday, 22 May 13
  • 22. Deprecated • ext/mysql !!!! • preg_replace() /e modifier, use preg_replace_callback() (good!) • IntlDateFormatter::setTimeZoneID() and datefmt_set_timezone_id() • some mcrypt functions • http://www.php.net/manual/en/migration55.deprecated.php Wednesday, 22 May 13
  • 23. Current status • First Release Candidate: 9 May • Second RC due out on 23rd May • Expected stable release soon Wednesday, 22 May 13