SlideShare a Scribd company logo
1 of 24
Download to read offline
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

Webrtc mojo
Webrtc mojoWebrtc mojo
Webrtc mojobpmedley
 
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 PerlHideaki Ohno
 
Melhorando sua API com DSLs
Melhorando sua API com DSLsMelhorando sua API com DSLs
Melhorando sua API com DSLsAugusto Pascutti
 
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 Aheadthinkphp
 
Smolder @Silex
Smolder @SilexSmolder @Silex
Smolder @SilexJeen Lee
 
Kansai.pm 10周年記念 Plack/PSGI 入門
Kansai.pm 10周年記念 Plack/PSGI 入門Kansai.pm 10周年記念 Plack/PSGI 入門
Kansai.pm 10周年記念 Plack/PSGI 入門lestrrat
 
GettingStartedWithPHP
GettingStartedWithPHPGettingStartedWithPHP
GettingStartedWithPHPNat Weerawan
 
Cli the other SAPI confoo11
Cli the other SAPI confoo11Cli the other SAPI confoo11
Cli the other SAPI confoo11Combell NV
 
CLI, the other SAPI phpnw11
CLI, the other SAPI phpnw11CLI, the other SAPI phpnw11
CLI, the other SAPI phpnw11Combell 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 extensionsMark 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 webclkao
 
Asynchronous I/O in PHP
Asynchronous I/O in PHPAsynchronous I/O in PHP
Asynchronous I/O in PHPThomas Weinert
 
Php 7 hhvm and co
Php 7 hhvm and coPhp 7 hhvm and co
Php 7 hhvm and coPierre Joye
 
Perl web frameworks
Perl web frameworksPerl web frameworks
Perl web frameworksdiego_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 AnswerIan 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

Question 1 for media evaluation pow
Question 1 for media evaluation powQuestion 1 for media evaluation pow
Question 1 for media evaluation powMaddie Bonneau
 
Whetstone u09a1.irregular verbs
Whetstone u09a1.irregular verbsWhetstone u09a1.irregular verbs
Whetstone u09a1.irregular verbsjillwhetstone
 
Rebeca salas y hilary jimenes
Rebeca salas y hilary jimenesRebeca salas y hilary jimenes
Rebeca salas y hilary jimenesRebeca Salas
 
ДНЗ № 189 ( круглый стол)
ДНЗ № 189 ( круглый стол)ДНЗ № 189 ( круглый стол)
ДНЗ № 189 ( круглый стол)olchik_p
 
Springley - Water Case Study
Springley - Water Case StudySpringley - Water Case Study
Springley - Water Case StudyFakhir Rehman
 
Презентация Васильківської ЗОШ І-ІІІ ст№8 "Військове містечко11""
Презентация Васильківської ЗОШ І-ІІІ ст№8 "Військове містечко11""Презентация Васильківської ЗОШ І-ІІІ ст№8 "Військове містечко11""
Презентация Васильківської ЗОШ І-ІІІ ст№8 "Військове містечко11""08600 Vasilkov
 
My Certificates - Volume 1
My Certificates - Volume 1My Certificates - Volume 1
My Certificates - Volume 1Tony Campanale
 
физкультурно оздоровительный блок
физкультурно оздоровительный блокфизкультурно оздоровительный блок
физкультурно оздоровительный блок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 planningJayme 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 Servicesstephenjbarr
 
Report of the science society
Report of the science societyReport of the science society
Report of the science societyhanisah67
 
Презентація команди Васильківської ЗОШ І-ІІІ ступенів №2
Презентація команди Васильківської ЗОШ І-ІІІ ступенів №2Презентація команди Васильківської ЗОШ І-ІІІ ступенів №2
Презентація команди Васильківської ЗОШ І-ІІІ ступенів №208600 Vasilkov
 
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 PHP 5.5 new features generators finally immutable

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
 
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
 
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
 
PHP Streams
PHP StreamsPHP Streams
PHP StreamsG Woo
 
Debugging: Rules & Tools
Debugging: Rules & ToolsDebugging: Rules & Tools
Debugging: Rules & ToolsIan Barber
 
PHP 5.3 Overview
PHP 5.3 OverviewPHP 5.3 Overview
PHP 5.3 Overviewjsmith92
 
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 VersionIan 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 2016Codemotion
 
Php7 HHVM and co
Php7 HHVM and coPhp7 HHVM and co
Php7 HHVM and coweltling
 
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 Herokuronnywang_tw
 
Php basic for vit university
Php basic for vit universityPhp basic for vit university
Php basic for vit universityMandakini Kumari
 
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
 
Php7 hhvm and co
Php7 hhvm and coPhp7 hhvm and co
Php7 hhvm and coPierre Joye
 
Time tested php with libtimemachine
Time tested php with libtimemachineTime tested php with libtimemachine
Time tested php with libtimemachineNick Galbreath
 

Similar to PHP 5.5 new features generators finally immutable (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

[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 

Recently uploaded (20)

[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 

PHP 5.5 new features generators finally immutable

  • 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