SlideShare a Scribd company logo
KEY FEATRURES
PHP 5.3 - 5.6
FEDERICO LOZADA MOSTO
Twitter: @mostofreddy
Web: mostofreddy.com.ar
Facebook: /mostofreddy
Linkedin: ar.linkedin.com/in/federicolozadamosto
Github: /mostofreddy
History
5.6.0 – 28/08/2014
5.5.0 – 20/06/2013
5.4.0 – 01/03/2012
5.3.0 – 30/07/2009
5.2.0 – 02/11/2006
5.1.0 – 24/11/2005
5.0.0 – 13/07/2004
Fuentes:
✓ http://php.net/eol.php
✓ http://php.net/supported-versions.php
!
PHP 5.3
Namespaces
<?php
namespace mostofreddylogger;
Class Logger {
…
}
?>
<?php
$log = new mostofreddyloggerLogger();
$log->info(“example of namespaces”);
//return example of namespaces
PHP 5.3
Lambdas & Closures
PHP 5.3
$sayHello = function() {
return "Hello world";
};
echo $sayHello();
//return Hello world
$text = "Hello %s";
$sayHello = function($name) use (&$text) {
return sprintf($text, $name);
};
echo $sayHello("phpbsas");
//return Hello phpbsas
PHP 5.4
JSON serializable
PHP 5.4
class Freddy implements JsonSerializable
{
public $data = [];
public function __construct() {
$this->data = array(
'Federico', 'Lozada', 'Mosto'
);
}
public function jsonSerialize() {return $this->data;}
}
echo json_encode(new Freddy());
//return ["Federico","Lozada","Mosto"]
//PHP < 5.4
//{"data":["Federico","Lozada","Mosto"]}
Session handler
PHP < 5.4
$obj = new MySessionHandler;
session_set_save_handler(
array($obj, "open"),
array($obj, "close"),
array($obj, "read"),
array($obj, "write"),
array($obj, "destroy"),
array($obj, "gc")
)
PHP 5.4
class MySessionHandler implements SessionHandlerInterface
{
public function open($savePath, $sessionName) {}
public function close() {}
public function read($id) {}
public function write($id, $data) {}
public function destroy($id) {}
public function gc($maxlifetime) {}
}
$handler = new MySessionHandler();
session_set_save_handler($handler, true);
session_start();
PHP 5.4
function status() {
$status = session_status();
if($status == PHP_SESSION_DISABLED) {
echo "Session is Disabled";
} else if($status == PHP_SESSION_NONE ) {
echo "Session Enabled but No Session values Created";
} else {
echo "Session Enabled and Session values Created";
}
}
status();
//return Session Enabled but No Session values Created
session_start();
status();
//return Session Enabled and Session values Created
Arrays
PHP 5.4
$array = [0, 1, 2, 3, 4];
var_dump($array);
//return
array(6) {
[0]=> int(0)
[1]=> int(1)
[2]=> int(2)
[3]=> int(3)
[4]=> int(4)
}
Short syntax
PHP 5.4Array Deferencing
$txt = "Hello World";
echo explode(" ", $txt)[0];
//return Hello World
function getName() {
return [
'user' => array(
'name'=>'Federico'
)
];
}
echo getName()['user']['name'];
//return Federico
Built-in web server
PHP 5.4
~/www$ php -S localhost:8080
PHP 5.4.0 Development Server started at Mon Apr
2 11:37:48 2012
Listening on localhost:8080
Document root is /var/www
Press Ctrl-C to quit.
PHP 5.4
~/www$ vim server.sh
#! /bin/bash
DOCROOT="/var/www"
HOST=0.0.0.0
PORT=80
ROUTER="/var/www/router.php"
PHP=$(which php)
if [ $? != 0 ] ; then
echo "Unable to find PHP"
exit 1
fi
$PHP -S $HOST:$PORT -t $DOCROOT $ROUTER
Traits
PHP 5.4
trait File {
public function put($m) {error_log($m, 3, '/tmp/log');}
}
trait Log {
use File;
public function addLog($m) {$this->put('LOG: '.$m);}
}
class Test {
use Log;
public function foo() { $this->addLog('test');}
}
$obj = new Test;
$obj->foo();
//return LOG: test
PHP 5.4
trait Game {
public function play() {return "Play Game";}
}
trait Music {
public function play() {return "Play Music";}
}
class Player {
use Game, Music;
}
$o = new Player;
echo $o->play();
Solving confict
PHP does not solve
conflicts automatically
PHP Fatal error: Trait method play has not been applied,
because there are collisions with other trait methods
on Player in /var/www/test/test_traits.php on line 10
PHP 5.4
trait Game {
public function play() {return "Play Game";}
}
trait Music {
public function play() {return "Play Music";}
}
class Player {
use Game, Music {
Game::play as gamePlay;
Music::play insteadof Game;
}
}
$o = new Player;
echo $o->play(); //return Play Music
echo $o->gamePlay(); //return Play Game
PHP 5.5
Generators
PHP < 5.5
function getLines($filename) {
if (!$handler = fopen($filename, 'r')) {
return;
}
$lines = [];
while (false != $line = fgets($handler)) {
$lines[] = $line;
}
fclose($handler);
return $lines;
}
$lines = getLines('file.txt');
foreach ($lines as $line) {
echo $line;
}
PHP 5.5
function getLines($filename) {
if (!$handler = fopen($filename, 'r')) {
return;
}
while (false != $line = fgets($handler)) {
yield $line;
}
fclose($handler);
}
foreach (getLines('file.txt') as $line) {
echo $line;
}
PHP with generators
Total time: 1.3618 seg
Memory: 256 k
PHP classic
Total time: 1.5684 seg
Memory: 2.5 M
PHP 5.5
OPCache
PHP 5.5
PHP 5.5
opcache.enable=1
opcache.enable_cli=1
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=60
opcache.fast_shutdown=1
Basic configuration
PHP 5.5
Advanced configuration for PHPUnit / Symfony /
Doctrine / Zend / etc
opcache.save_comments=1
opcache.enable_file_override=1
Functions
opcache_reset()
opcache_invalidate($filename, true)
Password Hashing API
PHP 5.5
password_get_info()
password_hash()
password_needs_rehash()
password_verify()
Funtions
PHP 5.5
$hash = password_hash($password, PASSWORD_DEFAULT);
//or
$hash = password_hash(
$password,
PASSWORD_DEFAULT, //default bcrypt
['cost'=>12, 'salt'=> 'asdadlashdoahdlkuagssa']
);
$user->setPass($hash);
$user->save();
PHP 5.5
$hash = $user->getPass();
if (!password_verify($password, $hash) {
throw new Exception('Invalid password');
}
if (password_needs_rehash($hash, PASSWORD_DEFAULT, ['cost' => 18]))
{
$hash = password_hash(
$password, PASSWORD_DEFAULT, ['cost' => 18]
);
$user->setPass($hash);
$user->save();
}
PHP 5.5
var_dump(password_get_info($hash1));
// prints
array(3) {
'algo' => int(1)
'algoName' => string(6) "bcrypt"
'options' => array(1) {
'cost' => int(12)
}
}
PHP 5.6
Variadic functions via …
&&
Argument unpacking via ...
PHP < 5.6
function ides() {
$cant = func_num_args();
echo "Ides count: ".$cant;
}
ides('Eclipse', 'Netbeas');
// Ides count 2
PHP 5.6
function ides($ide, ...$ides) {
echo "Ides count: ".count($ides);
}
ides (
'Eclipse', 'Netbeas', 'Sublime'
);
// Ides count 2
PHP 5.6
function sum(...$numbers) {
$acc = 0;
foreach ($numbers as $n) {
$acc += $n;
}
return $acc;
}
echo sum(1, 2, 3, 4);
// 10
PHP 5.6
function add($a, $b) {
return $a + $b;
}
echo add(...[1, 2]);
// 3
$a = [1, 2];
echo add(...$a);
// 3
PHP 5.6
function showNames($welcome, Person ...$people) {
echo $welcome.PHP_EOL;
foreach ($people as $person) {
echo $person->name.PHP_EOL;
}
}
$a = new Person('Federico');
$b = new Person('Damian');
showNames('Welcome: ', $a, $b);
//Welcome:
//Federico
//Damian
__debugInfo()
PHP 5.6
class C {
private $prop;
public function __construct($val) {
$this->prop = $val;
}
public function __debugInfo() {
return [
'propSquared' => $this->prop ** 2
];
}
}
var_dump(new C(42));
// object(C)#1 (1) {
["propSquared"]=> int(1764)
}
Questions?
FEDERICO LOZADA MOSTO
TW: @mostofreddy
Web: mostofreddy.com.ar
FB: mostofreddy
In: ar.linkedin.com/in/federicolozadamosto
Git: mostofreddy
Thanks!

More Related Content

What's hot (20)

ODP
The why and how of moving to PHP 5.5/5.6
Wim Godden
 
PDF
Quick tour of PHP from inside
julien pauli
 
PPTX
Php 7 hhvm and co
Pierre Joye
 
PPTX
PHP7 Presentation
David Sanchez
 
PDF
Introduction to PHP
Bradley Holt
 
KEY
Anatomy of a PHP Request ( UTOSC 2010 )
Joseph Scott
 
PDF
PHP7 is coming
julien pauli
 
PPT
The Php Life Cycle
Xinchen Hui
 
PDF
Introduction to PHP - Basics of PHP
wahidullah mudaser
 
PDF
Mysqlnd, an unknown powerful PHP extension
julien pauli
 
KEY
GettingStartedWithPHP
Nat Weerawan
 
PPTX
A new way to develop with WordPress!
David Sanchez
 
PPTX
10 Most Important Features of New PHP 5.6
Webline Infosoft P Ltd
 
KEY
Yapcasia2011 - Hello Embed Perl
Hideaki Ohno
 
PPTX
Php.ppt
Nidhi mishra
 
PDF
New Features in PHP 5.3
Bradley Holt
 
ZIP
Web Apps in Perl - HTTP 101
hendrikvb
 
PDF
Understanding PHP memory
julien pauli
 
PDF
Modern PHP
Simon Jones
 
PDF
Profiling php5 to php7
julien pauli
 
The why and how of moving to PHP 5.5/5.6
Wim Godden
 
Quick tour of PHP from inside
julien pauli
 
Php 7 hhvm and co
Pierre Joye
 
PHP7 Presentation
David Sanchez
 
Introduction to PHP
Bradley Holt
 
Anatomy of a PHP Request ( UTOSC 2010 )
Joseph Scott
 
PHP7 is coming
julien pauli
 
The Php Life Cycle
Xinchen Hui
 
Introduction to PHP - Basics of PHP
wahidullah mudaser
 
Mysqlnd, an unknown powerful PHP extension
julien pauli
 
GettingStartedWithPHP
Nat Weerawan
 
A new way to develop with WordPress!
David Sanchez
 
10 Most Important Features of New PHP 5.6
Webline Infosoft P Ltd
 
Yapcasia2011 - Hello Embed Perl
Hideaki Ohno
 
Php.ppt
Nidhi mishra
 
New Features in PHP 5.3
Bradley Holt
 
Web Apps in Perl - HTTP 101
hendrikvb
 
Understanding PHP memory
julien pauli
 
Modern PHP
Simon Jones
 
Profiling php5 to php7
julien pauli
 

Similar to Key features PHP 5.3 - 5.6 (20)

PDF
The new features of PHP 7 - Enrico Zimuel - Codemotion Milan 2016
Codemotion
 
PDF
PHP Without PHP—Confoo
terry chay
 
PPT
ZendCon 08 php 5.3
webhostingguy
 
PPT
Php mysql ppt
Karmatechnologies Pvt. Ltd.
 
ODP
The why and how of moving to php 5.4/5.5
Wim Godden
 
PDF
Php 7 compliance workshop singapore
Damien Seguy
 
PPT
Php with my sql
husnara mohammad
 
PDF
basic concept of php(Gunikhan sonowal)
Guni Sonow
 
PDF
What's new with PHP7
SWIFTotter Solutions
 
PPT
Php Tutorial
SHARANBAJWA
 
PPT
Introducation to php for beginners
musrath mohammad
 
PPTX
HackU PHP and Node.js
souridatta
 
PDF
An introduction to PHP 5.4
Giovanni Derks
 
PDF
Apache and PHP: Why httpd.conf is your new BFF!
Jeff Jones
 
PDF
関西PHP勉強会 php5.4つまみぐい
Hisateru Tanaka
 
PDF
Debugging: Rules & Tools
Ian Barber
 
PPTX
PHP Basics and Demo HackU
Anshu Prateek
 
PDF
Die .htaccess richtig nutzen
Walter Ebert
 
PPTX
PHP File Handling
Degu8
 
The new features of PHP 7 - Enrico Zimuel - Codemotion Milan 2016
Codemotion
 
PHP Without PHP—Confoo
terry chay
 
ZendCon 08 php 5.3
webhostingguy
 
The why and how of moving to php 5.4/5.5
Wim Godden
 
Php 7 compliance workshop singapore
Damien Seguy
 
Php with my sql
husnara mohammad
 
basic concept of php(Gunikhan sonowal)
Guni Sonow
 
What's new with PHP7
SWIFTotter Solutions
 
Php Tutorial
SHARANBAJWA
 
Introducation to php for beginners
musrath mohammad
 
HackU PHP and Node.js
souridatta
 
An introduction to PHP 5.4
Giovanni Derks
 
Apache and PHP: Why httpd.conf is your new BFF!
Jeff Jones
 
関西PHP勉強会 php5.4つまみぐい
Hisateru Tanaka
 
Debugging: Rules & Tools
Ian Barber
 
PHP Basics and Demo HackU
Anshu Prateek
 
Die .htaccess richtig nutzen
Walter Ebert
 
PHP File Handling
Degu8
 
Ad

More from Federico Damián Lozada Mosto (8)

PDF
Solid Principles & Design patterns with PHP examples
Federico Damián Lozada Mosto
 
PDF
Implementando una Arquitectura de Microservicios
Federico Damián Lozada Mosto
 
PDF
Travis-CI - Continuos integration in the cloud for PHP
Federico Damián Lozada Mosto
 
PDF
Introduction to unit testing
Federico Damián Lozada Mosto
 
Solid Principles & Design patterns with PHP examples
Federico Damián Lozada Mosto
 
Implementando una Arquitectura de Microservicios
Federico Damián Lozada Mosto
 
Travis-CI - Continuos integration in the cloud for PHP
Federico Damián Lozada Mosto
 
Introduction to unit testing
Federico Damián Lozada Mosto
 
Ad

Recently uploaded (20)

PPTX
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
PPTX
Finding Your License Details in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
PPTX
iaas vs paas vs saas :choosing your cloud strategy
CloudlayaTechnology
 
PDF
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
PDF
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
PDF
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 
PDF
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
PDF
How to Hire AI Developers_ Step-by-Step Guide in 2025.pdf
DianApps Technologies
 
PDF
The 5 Reasons for IT Maintenance - Arna Softech
Arna Softech
 
PDF
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
PPTX
Get Started with Maestro: Agent, Robot, and Human in Action – Session 5 of 5
klpathrudu
 
PDF
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
PPTX
Milwaukee Marketo User Group - Summer Road Trip: Mapping and Personalizing Yo...
bbedford2
 
PDF
ERP Consulting Services and Solutions by Contetra Pvt Ltd
jayjani123
 
PPTX
Home Care Tools: Benefits, features and more
Third Rock Techkno
 
PDF
AI Prompts Cheat Code prompt engineering
Avijit Kumar Roy
 
PPTX
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
PPTX
Homogeneity of Variance Test Options IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PPTX
Function & Procedure: Function Vs Procedure in PL/SQL
Shani Tiwari
 
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
Finding Your License Details in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
iaas vs paas vs saas :choosing your cloud strategy
CloudlayaTechnology
 
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
How to Hire AI Developers_ Step-by-Step Guide in 2025.pdf
DianApps Technologies
 
The 5 Reasons for IT Maintenance - Arna Softech
Arna Softech
 
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
Get Started with Maestro: Agent, Robot, and Human in Action – Session 5 of 5
klpathrudu
 
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
Milwaukee Marketo User Group - Summer Road Trip: Mapping and Personalizing Yo...
bbedford2
 
ERP Consulting Services and Solutions by Contetra Pvt Ltd
jayjani123
 
Home Care Tools: Benefits, features and more
Third Rock Techkno
 
AI Prompts Cheat Code prompt engineering
Avijit Kumar Roy
 
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
Homogeneity of Variance Test Options IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Function & Procedure: Function Vs Procedure in PL/SQL
Shani Tiwari
 

Key features PHP 5.3 - 5.6

  • 2. FEDERICO LOZADA MOSTO Twitter: @mostofreddy Web: mostofreddy.com.ar Facebook: /mostofreddy Linkedin: ar.linkedin.com/in/federicolozadamosto Github: /mostofreddy
  • 4. 5.6.0 – 28/08/2014 5.5.0 – 20/06/2013 5.4.0 – 01/03/2012 5.3.0 – 30/07/2009 5.2.0 – 02/11/2006 5.1.0 – 24/11/2005 5.0.0 – 13/07/2004 Fuentes: ✓ http://php.net/eol.php ✓ http://php.net/supported-versions.php !
  • 7. <?php namespace mostofreddylogger; Class Logger { … } ?> <?php $log = new mostofreddyloggerLogger(); $log->info(“example of namespaces”); //return example of namespaces PHP 5.3
  • 9. PHP 5.3 $sayHello = function() { return "Hello world"; }; echo $sayHello(); //return Hello world $text = "Hello %s"; $sayHello = function($name) use (&$text) { return sprintf($text, $name); }; echo $sayHello("phpbsas"); //return Hello phpbsas
  • 12. PHP 5.4 class Freddy implements JsonSerializable { public $data = []; public function __construct() { $this->data = array( 'Federico', 'Lozada', 'Mosto' ); } public function jsonSerialize() {return $this->data;} } echo json_encode(new Freddy()); //return ["Federico","Lozada","Mosto"] //PHP < 5.4 //{"data":["Federico","Lozada","Mosto"]}
  • 14. PHP < 5.4 $obj = new MySessionHandler; session_set_save_handler( array($obj, "open"), array($obj, "close"), array($obj, "read"), array($obj, "write"), array($obj, "destroy"), array($obj, "gc") )
  • 15. PHP 5.4 class MySessionHandler implements SessionHandlerInterface { public function open($savePath, $sessionName) {} public function close() {} public function read($id) {} public function write($id, $data) {} public function destroy($id) {} public function gc($maxlifetime) {} } $handler = new MySessionHandler(); session_set_save_handler($handler, true); session_start();
  • 16. PHP 5.4 function status() { $status = session_status(); if($status == PHP_SESSION_DISABLED) { echo "Session is Disabled"; } else if($status == PHP_SESSION_NONE ) { echo "Session Enabled but No Session values Created"; } else { echo "Session Enabled and Session values Created"; } } status(); //return Session Enabled but No Session values Created session_start(); status(); //return Session Enabled and Session values Created
  • 18. PHP 5.4 $array = [0, 1, 2, 3, 4]; var_dump($array); //return array(6) { [0]=> int(0) [1]=> int(1) [2]=> int(2) [3]=> int(3) [4]=> int(4) } Short syntax
  • 19. PHP 5.4Array Deferencing $txt = "Hello World"; echo explode(" ", $txt)[0]; //return Hello World function getName() { return [ 'user' => array( 'name'=>'Federico' ) ]; } echo getName()['user']['name']; //return Federico
  • 21. PHP 5.4 ~/www$ php -S localhost:8080 PHP 5.4.0 Development Server started at Mon Apr 2 11:37:48 2012 Listening on localhost:8080 Document root is /var/www Press Ctrl-C to quit.
  • 22. PHP 5.4 ~/www$ vim server.sh #! /bin/bash DOCROOT="/var/www" HOST=0.0.0.0 PORT=80 ROUTER="/var/www/router.php" PHP=$(which php) if [ $? != 0 ] ; then echo "Unable to find PHP" exit 1 fi $PHP -S $HOST:$PORT -t $DOCROOT $ROUTER
  • 24. PHP 5.4 trait File { public function put($m) {error_log($m, 3, '/tmp/log');} } trait Log { use File; public function addLog($m) {$this->put('LOG: '.$m);} } class Test { use Log; public function foo() { $this->addLog('test');} } $obj = new Test; $obj->foo(); //return LOG: test
  • 25. PHP 5.4 trait Game { public function play() {return "Play Game";} } trait Music { public function play() {return "Play Music";} } class Player { use Game, Music; } $o = new Player; echo $o->play(); Solving confict PHP does not solve conflicts automatically PHP Fatal error: Trait method play has not been applied, because there are collisions with other trait methods on Player in /var/www/test/test_traits.php on line 10
  • 26. PHP 5.4 trait Game { public function play() {return "Play Game";} } trait Music { public function play() {return "Play Music";} } class Player { use Game, Music { Game::play as gamePlay; Music::play insteadof Game; } } $o = new Player; echo $o->play(); //return Play Music echo $o->gamePlay(); //return Play Game
  • 29. PHP < 5.5 function getLines($filename) { if (!$handler = fopen($filename, 'r')) { return; } $lines = []; while (false != $line = fgets($handler)) { $lines[] = $line; } fclose($handler); return $lines; } $lines = getLines('file.txt'); foreach ($lines as $line) { echo $line; }
  • 30. PHP 5.5 function getLines($filename) { if (!$handler = fopen($filename, 'r')) { return; } while (false != $line = fgets($handler)) { yield $line; } fclose($handler); } foreach (getLines('file.txt') as $line) { echo $line; }
  • 31. PHP with generators Total time: 1.3618 seg Memory: 256 k PHP classic Total time: 1.5684 seg Memory: 2.5 M PHP 5.5
  • 35. PHP 5.5 Advanced configuration for PHPUnit / Symfony / Doctrine / Zend / etc opcache.save_comments=1 opcache.enable_file_override=1 Functions opcache_reset() opcache_invalidate($filename, true)
  • 38. PHP 5.5 $hash = password_hash($password, PASSWORD_DEFAULT); //or $hash = password_hash( $password, PASSWORD_DEFAULT, //default bcrypt ['cost'=>12, 'salt'=> 'asdadlashdoahdlkuagssa'] ); $user->setPass($hash); $user->save();
  • 39. PHP 5.5 $hash = $user->getPass(); if (!password_verify($password, $hash) { throw new Exception('Invalid password'); } if (password_needs_rehash($hash, PASSWORD_DEFAULT, ['cost' => 18])) { $hash = password_hash( $password, PASSWORD_DEFAULT, ['cost' => 18] ); $user->setPass($hash); $user->save(); }
  • 40. PHP 5.5 var_dump(password_get_info($hash1)); // prints array(3) { 'algo' => int(1) 'algoName' => string(6) "bcrypt" 'options' => array(1) { 'cost' => int(12) } }
  • 42. Variadic functions via … && Argument unpacking via ...
  • 43. PHP < 5.6 function ides() { $cant = func_num_args(); echo "Ides count: ".$cant; } ides('Eclipse', 'Netbeas'); // Ides count 2
  • 44. PHP 5.6 function ides($ide, ...$ides) { echo "Ides count: ".count($ides); } ides ( 'Eclipse', 'Netbeas', 'Sublime' ); // Ides count 2
  • 45. PHP 5.6 function sum(...$numbers) { $acc = 0; foreach ($numbers as $n) { $acc += $n; } return $acc; } echo sum(1, 2, 3, 4); // 10
  • 46. PHP 5.6 function add($a, $b) { return $a + $b; } echo add(...[1, 2]); // 3 $a = [1, 2]; echo add(...$a); // 3
  • 47. PHP 5.6 function showNames($welcome, Person ...$people) { echo $welcome.PHP_EOL; foreach ($people as $person) { echo $person->name.PHP_EOL; } } $a = new Person('Federico'); $b = new Person('Damian'); showNames('Welcome: ', $a, $b); //Welcome: //Federico //Damian
  • 49. PHP 5.6 class C { private $prop; public function __construct($val) { $this->prop = $val; } public function __debugInfo() { return [ 'propSquared' => $this->prop ** 2 ]; } } var_dump(new C(42)); // object(C)#1 (1) { ["propSquared"]=> int(1764) }
  • 51. FEDERICO LOZADA MOSTO TW: @mostofreddy Web: mostofreddy.com.ar FB: mostofreddy In: ar.linkedin.com/in/federicolozadamosto Git: mostofreddy Thanks!