SlideShare a Scribd company logo
Introducing new version
Version 1.2 - 6/08/2015
Table of contents
● Preamble
● PHP5.6: in case you missed something
a. Overview
b. New features
● PHP7: future is coming
a. Overview
b. What's new
Preamble
● Use filter_var()
// Check valid email
bool filter_var('example@site.tld', FILTER_VALIDATE_EMAIL);
// Remove empty values
$data = array(
'value1' => '',
'value2' => null,
'value3' => []
);
filter_var_array($data); // return empty array
● Speed the code
DON'T open/close PHP tags for excessive.
DON'T use GLOBALS
● release date: August 2014
● PHP5: last branch release
PHP5.6: Overview
PHP5.6: New features
● Constant expressions
const ONE = 1;
// Scalar Expression in constant
const TWO = ONE * 2;
● Variadic functions/Argument unpacking
function myTools($name, ...$tools) {
echo "Name:". $name.'<br />';
echo "My Tool Count:". count(tools);
}
myTools('Avinash', 'Eclipse');
myTools('Avinash', 'Eclipse', 'Sublime');
myTools('Avinash', 'Eclipse', 'Sublime', 'PHPStorm');
function myTools($name, $tool1, $tool2, $tool3) {
echo "Name:". $name.'<br />';
echo "Tool1:", $tool1.'<br />';
echo "Tool2:", $tool2.'<br />';
echo "Tool3:", $tool3;
}
$myTools = ['Eclipse', 'Sublime', 'PHPStorm'];
myTools('Avinash', ...$myTools);
PHP5.6: New features
● Exponentiation
// PHP5.5 and before
pow(2, 8); // 256
// PHP5.6 and after
echo 2 ** 8; // 256
echo 2 ** 2 ** 4; // 256
● use function and use const
namespace NameSpace {
const FOO = 42;
function f() { echo __FUNCTION__."n"; }
}
namespace {
use const NameSpaceFOO;
use function NameSpacef;
echo FOO."n";
f();
}
PHP5.6: New features
● phpdbg: The interactive debugger
http://phpdbg.com/docs
● php://input
// Now deprecated
$HTTP_RAW_POST_DATA
// This is now reusable
file_get_contents('php://input');
● Large file uploads
Files larger than 2 gigabytes in size are now accepted.
PHP5.6: New features
● __debugInfo()
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)
}
● Release date: October 2015
● Engine: Zend v3 (32/64 bits)
● Performance: 25% to 70% faster
● Backward Incompatible Changes
● New Parser
● Tidy up old things
● Many new features
PHP7: Overview
● Scalar Type Declarations
// must be the first statement in a file.
// If it appears anywhere else in the file it will generate a compiler error.
declare(strict_types=1);
// Available type hints
int, float, string, bool
// Examples
function add(string $a, string $b): string {
return $a + $b;
}
function add(int $a, int $b): int {
return $a + $b;
}
function add(float $a, float $b): float {
return $a + $b;
}
function add(bool $a, bool $b): bool {
return $a + $b;
}
PHP7: What's new
● Group Use Declarations
// PHP7
use FooLibraryBarBaz{ ClassA, ClassB, ClassC, ClassD as Fizbo };
// Before PHP7
use FooLibraryBarBazClassA;
use FooLibraryBarBazClassB;
use FooLibraryBarBazClassC;
use FooLibraryBarBazClassD as Fizbo;
● switch.default.multiple
Will raise E_COMPILE_ERROR when multiple default blocks are found in a switch statement.
PHP7: What's new
● Alternative PHP tags removed
<% // opening tag
<%= // opening tag with echo
%> // closing tag
(<scripts+languages*=s*(php|"php"|'php')s*>)i // opening tag
(</script>)i // closing tag
● Return Type Declarations
// Returning array // Overriding a method that did not
have a return type:
function foo(): array { interface Comment {}
return []; interface CommentsIterator extends
Iterator {
} function
current(): Comment;
}
// Returning object
interface A {
static function make(): A;
}
class B implements A {
static function make(): A {
return new B();
}
}
PHP7: What's new
● Update json parser extension
json extension has been replaced by jsond extension
echo json_encode(10.0); // Output 10
echo json_encode(10.1); // Output 10.1
echo json_encode(10.0, JSON_PRESERVE_ZERO_FRACTION); // Output 10.0
echo json_encode(10.1, JSON_PRESERVE_ZERO_FRACTION); // Output 10.1
var_dump(json_decode(json_encode(10.0, JSON_PRESERVE_ZERO_FRACTION))); // Output double(10)
var_dump(10.0 === json_decode(json_encode(10.0, JSON_PRESERVE_ZERO_FRACTION))); // Output bool(true)
● Removing old codes
PHP4 constructor
Removal of dead/unmaintained/deprecated SAPIs and extensions (imap, mcrypt, mysql, ereg,
aolserver, isapi, ...)
Remove the date.timezone warning
PHP7: What's new
● new operators
o Nullsafe Calls
function f($o) {
$o2 = $o->mayFail1();
if ($o2 === null) {
return null;
}
$o3 = $o2->mayFail2();
if ($o3 === null) {
return null;
}
$o4 = $o3->mayFail3();
if ($o4 === null) {
return null;
}
return $o4->mayFail4();
}
function f($o) {
return $o?->mayFail1()?->mayFail2()?->mayFail3()?->mayFail4();
}
PHP7: What's new
● new operators
o Spaceship
PHP7: What's new
operator <=> equivalent
$a < $b ($a <=> $b) === -1
$a <= $b ($a <=> $b) === -1 || ($a <=> $b) === 0
$a == $b ($a <=> $b) === 0
$a != $b ($a <=> $b) !== 0
$a >= $b ($a <=> $b) === 1 || ($a <=> $b) === 0
$a > $b ($a <=> $b) === 1
● new operators
o Null Coalesce
// Without null coalesce
$username = isset($_GET['user']) ? $_GET['user'] : 'nobody';
// With null coalesce
$username = $_GET['user'] ?? 'nobody';
PHP7: What's new
● Context Sensitive Lexer
PHP7: What's new
Newly reserved Now possible
int Class::forEach()
float Class::list()
bool Class::for()
string Class::and()
true, false Class::or()
null Class::new()
Class::include()
const CONTINUE
● Anonymous class support
/* implementing an anonymous console object from your framework maybe */
(new class extends ConsoleProgram {
public function main() {
/* ... */
}
})->bootstrap();
class Foo {}
$child = new class extends Foo {};
var_dump($child instanceof Foo); // true
// New Hotness
$pusher->setLogger(new class {
public function log($msg) {
print_r($msg . "n");
}
});
PHP7: What's new
● Uniform Variable Syntax
// old meaning // new meaning
$$foo['bar']['baz'] ${$foo['bar']['baz']} ($$foo)['bar']['baz']
$foo->$bar['baz'] $foo->{$bar['baz']} ($foo->$bar)['baz']
$foo->$bar['baz']() $foo->{$bar['baz']}() ($foo->$bar)['baz']()
Foo::$bar['baz']() Foo::{$bar['baz']}() (Foo::$bar)['baz']()
// Before
global $$foo->bar;
// Instead use
global ${$foo->bar};
● Unicode Codepoint Escape Syntax
"U+202E" // String composed by U+ will now not be parsed as special characters
echo "u{1F602}"; // outputs 😂
● Instance class by reference not working anymore
$class = &new Class(); // Will now return a Parse error
PHP7: What's new
● Loop else
foreach ($array as $x) {
echo "Name: {$x->name}n";
} else {
echo "No records found!n";
}
● Named Parameters
// Using positional arguments:
htmlspecialchars($string, double_encode => false);
// Same as
htmlspecialchars($string, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
// non changing default value
htmlspecialchars($string, default, default, false);
PHP7: Proposed features/In draft
● Union Types: multi types
function (array|Traversable $in) {
foreach ($in as $value) {
echo $value, PHP_EOL;
}
}
● Enum types
enum RenewalAction {
Deny,
Approve
}
function other(RenewalAction $action): RenewalAction {
switch ($action) {
case RenewalAction::Approve:
return RenewalAction::Deny;
case RenewalAction::Deny:
return RenewalAction::Approve;
}
}
PHP7: Proposed features/In draft
PHPNG: Next Generation
● PHP8.0: 2020
● PHP9.0: 2025
PHP7: References
● PHP: rfc
● Etat des lieux et avenir de PHP
● En route pour PHP7

More Related Content

What's hot

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
 
Doctrine 2.0 Enterprise Persistence Layer for PHP
Doctrine 2.0 Enterprise Persistence Layer for PHPDoctrine 2.0 Enterprise Persistence Layer for PHP
Doctrine 2.0 Enterprise Persistence Layer for PHP
Guilherme Blanco
 
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
 
PHP Tips for certification - OdW13
PHP Tips for certification - OdW13PHP Tips for certification - OdW13
PHP Tips for certification - OdW13
julien pauli
 
関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい
Hisateru Tanaka
 
PHP 7 Crash Course - php[world] 2015
PHP 7 Crash Course - php[world] 2015PHP 7 Crash Course - php[world] 2015
PHP 7 Crash Course - php[world] 2015
Colin O'Dell
 
Introducing PHP Latest Updates
Introducing PHP Latest UpdatesIntroducing PHP Latest Updates
Introducing PHP Latest Updates
Iftekhar Eather
 
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
 
What's new in PHP 5.5
What's new in PHP 5.5What's new in PHP 5.5
What's new in PHP 5.5
Tom Corrigan
 
Diving into HHVM Extensions (PHPNW Conference 2015)
Diving into HHVM Extensions (PHPNW Conference 2015)Diving into HHVM Extensions (PHPNW Conference 2015)
Diving into HHVM Extensions (PHPNW Conference 2015)
James Titcumb
 
Webrtc mojo
Webrtc mojoWebrtc mojo
Webrtc mojo
bpmedley
 
Codeigniter4の比較と検証
Codeigniter4の比較と検証Codeigniter4の比較と検証
Codeigniter4の比較と検証
ME iBotch
 
Understanding PHP objects
Understanding PHP objectsUnderstanding PHP objects
Understanding PHP objects
julien pauli
 
Quick tour of PHP from inside
Quick tour of PHP from insideQuick tour of PHP from inside
Quick tour of PHP from inside
julien pauli
 
Perl web frameworks
Perl web frameworksPerl web frameworks
Perl web frameworks
diego_k
 
PHP 良好實踐 (Best Practice)
PHP 良好實踐 (Best Practice)PHP 良好實踐 (Best Practice)
PHP 良好實踐 (Best Practice)
Win Yu
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
Bradley Holt
 
web2py:Web development like a boss
web2py:Web development like a bossweb2py:Web development like a boss
web2py:Web development like a boss
Francisco Ribeiro
 
Php 7 hhvm and co
Php 7 hhvm and coPhp 7 hhvm and co
Php 7 hhvm and co
Pierre Joye
 
PHP POWERPOINT SLIDES
PHP POWERPOINT SLIDESPHP POWERPOINT SLIDES
PHP POWERPOINT SLIDES
Ismail Mukiibi
 

What's hot (20)

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
 
Doctrine 2.0 Enterprise Persistence Layer for PHP
Doctrine 2.0 Enterprise Persistence Layer for PHPDoctrine 2.0 Enterprise Persistence Layer for PHP
Doctrine 2.0 Enterprise Persistence Layer for PHP
 
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)
 
PHP Tips for certification - OdW13
PHP Tips for certification - OdW13PHP Tips for certification - OdW13
PHP Tips for certification - OdW13
 
関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい
 
PHP 7 Crash Course - php[world] 2015
PHP 7 Crash Course - php[world] 2015PHP 7 Crash Course - php[world] 2015
PHP 7 Crash Course - php[world] 2015
 
Introducing PHP Latest Updates
Introducing PHP Latest UpdatesIntroducing PHP Latest Updates
Introducing PHP Latest Updates
 
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
 
What's new in PHP 5.5
What's new in PHP 5.5What's new in PHP 5.5
What's new in PHP 5.5
 
Diving into HHVM Extensions (PHPNW Conference 2015)
Diving into HHVM Extensions (PHPNW Conference 2015)Diving into HHVM Extensions (PHPNW Conference 2015)
Diving into HHVM Extensions (PHPNW Conference 2015)
 
Webrtc mojo
Webrtc mojoWebrtc mojo
Webrtc mojo
 
Codeigniter4の比較と検証
Codeigniter4の比較と検証Codeigniter4の比較と検証
Codeigniter4の比較と検証
 
Understanding PHP objects
Understanding PHP objectsUnderstanding PHP objects
Understanding PHP objects
 
Quick tour of PHP from inside
Quick tour of PHP from insideQuick tour of PHP from inside
Quick tour of PHP from inside
 
Perl web frameworks
Perl web frameworksPerl web frameworks
Perl web frameworks
 
PHP 良好實踐 (Best Practice)
PHP 良好實踐 (Best Practice)PHP 良好實踐 (Best Practice)
PHP 良好實踐 (Best Practice)
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
 
web2py:Web development like a boss
web2py:Web development like a bossweb2py:Web development like a boss
web2py:Web development like a boss
 
Php 7 hhvm and co
Php 7 hhvm and coPhp 7 hhvm and co
Php 7 hhvm and co
 
PHP POWERPOINT SLIDES
PHP POWERPOINT SLIDESPHP POWERPOINT SLIDES
PHP POWERPOINT SLIDES
 

Similar to PHP7 Presentation

Php 5.6 From the Inside Out
Php 5.6 From the Inside OutPhp 5.6 From the Inside Out
Php 5.6 From the Inside Out
Ferenc Kovács
 
PHP 8: Process & Fixing Insanity
PHP 8: Process & Fixing InsanityPHP 8: Process & Fixing Insanity
PHP 8: Process & Fixing Insanity
GeorgePeterBanyard
 
Building Custom PHP Extensions
Building Custom PHP ExtensionsBuilding Custom PHP Extensions
Building Custom PHP Extensions
AzRy LLC, Caucasus School of Technology
 
Giới thiệu PHP 7
Giới thiệu PHP 7Giới thiệu PHP 7
Giới thiệu PHP 7
ZendVN
 
Php 5.6
Php 5.6Php 5.6
PHP Versions Upgradation - What's New vs Old Version.pdf
PHP Versions Upgradation - What's New vs Old Version.pdfPHP Versions Upgradation - What's New vs Old Version.pdf
PHP Versions Upgradation - What's New vs Old Version.pdf
WPWeb Infotech
 
Getting started with TDD - Confoo 2014
Getting started with TDD - Confoo 2014Getting started with TDD - Confoo 2014
Getting started with TDD - Confoo 2014
Eric Hogue
 
Create your own PHP extension, step by step - phpDay 2012 Verona
Create your own PHP extension, step by step - phpDay 2012 VeronaCreate your own PHP extension, step by step - phpDay 2012 Verona
Create your own PHP extension, step by step - phpDay 2012 Verona
Patrick Allaert
 
Living With Legacy Code
Living With Legacy CodeLiving With Legacy Code
Living With Legacy Code
Rowan Merewood
 
PHP in 2018 - Q4 - AFUP Limoges
PHP in 2018 - Q4 - AFUP LimogesPHP in 2018 - Q4 - AFUP Limoges
PHP in 2018 - Q4 - AFUP Limoges
✅ William Pinaud
 
Unittests für Dummies
Unittests für DummiesUnittests für Dummies
Unittests für Dummies
Lars Jankowfsky
 
Diving into HHVM Extensions (Brno PHP Conference 2015)
Diving into HHVM Extensions (Brno PHP Conference 2015)Diving into HHVM Extensions (Brno PHP Conference 2015)
Diving into HHVM Extensions (Brno PHP Conference 2015)
James Titcumb
 
ElePHPant7 - Introduction to PHP7
ElePHPant7 - Introduction to PHP7ElePHPant7 - Introduction to PHP7
ElePHPant7 - Introduction to PHP7
Muhammad Hafiz Hasan
 
Fatc
FatcFatc
JavaScript for PHP developers
JavaScript for PHP developersJavaScript for PHP developers
JavaScript for PHP developers
Stoyan Stefanov
 
PHP 5.3 Overview
PHP 5.3 OverviewPHP 5.3 Overview
PHP 5.3 Overview
jsmith92
 
Dependency injection in Drupal 8
Dependency injection in Drupal 8Dependency injection in Drupal 8
Dependency injection in Drupal 8
Alexei Gorobets
 
What's new with PHP7
What's new with PHP7What's new with PHP7
What's new with PHP7
SWIFTotter Solutions
 
Jsphp 110312161301-phpapp02
Jsphp 110312161301-phpapp02Jsphp 110312161301-phpapp02
Jsphp 110312161301-phpapp02
Seri Moth
 
DIG1108 Lesson 6
DIG1108 Lesson 6DIG1108 Lesson 6
DIG1108 Lesson 6
vc-dig1108-fall-2013
 

Similar to PHP7 Presentation (20)

Php 5.6 From the Inside Out
Php 5.6 From the Inside OutPhp 5.6 From the Inside Out
Php 5.6 From the Inside Out
 
PHP 8: Process & Fixing Insanity
PHP 8: Process & Fixing InsanityPHP 8: Process & Fixing Insanity
PHP 8: Process & Fixing Insanity
 
Building Custom PHP Extensions
Building Custom PHP ExtensionsBuilding Custom PHP Extensions
Building Custom PHP Extensions
 
Giới thiệu PHP 7
Giới thiệu PHP 7Giới thiệu PHP 7
Giới thiệu PHP 7
 
Php 5.6
Php 5.6Php 5.6
Php 5.6
 
PHP Versions Upgradation - What's New vs Old Version.pdf
PHP Versions Upgradation - What's New vs Old Version.pdfPHP Versions Upgradation - What's New vs Old Version.pdf
PHP Versions Upgradation - What's New vs Old Version.pdf
 
Getting started with TDD - Confoo 2014
Getting started with TDD - Confoo 2014Getting started with TDD - Confoo 2014
Getting started with TDD - Confoo 2014
 
Create your own PHP extension, step by step - phpDay 2012 Verona
Create your own PHP extension, step by step - phpDay 2012 VeronaCreate your own PHP extension, step by step - phpDay 2012 Verona
Create your own PHP extension, step by step - phpDay 2012 Verona
 
Living With Legacy Code
Living With Legacy CodeLiving With Legacy Code
Living With Legacy Code
 
PHP in 2018 - Q4 - AFUP Limoges
PHP in 2018 - Q4 - AFUP LimogesPHP in 2018 - Q4 - AFUP Limoges
PHP in 2018 - Q4 - AFUP Limoges
 
Unittests für Dummies
Unittests für DummiesUnittests für Dummies
Unittests für Dummies
 
Diving into HHVM Extensions (Brno PHP Conference 2015)
Diving into HHVM Extensions (Brno PHP Conference 2015)Diving into HHVM Extensions (Brno PHP Conference 2015)
Diving into HHVM Extensions (Brno PHP Conference 2015)
 
ElePHPant7 - Introduction to PHP7
ElePHPant7 - Introduction to PHP7ElePHPant7 - Introduction to PHP7
ElePHPant7 - Introduction to PHP7
 
Fatc
FatcFatc
Fatc
 
JavaScript for PHP developers
JavaScript for PHP developersJavaScript for PHP developers
JavaScript for PHP developers
 
PHP 5.3 Overview
PHP 5.3 OverviewPHP 5.3 Overview
PHP 5.3 Overview
 
Dependency injection in Drupal 8
Dependency injection in Drupal 8Dependency injection in Drupal 8
Dependency injection in Drupal 8
 
What's new with PHP7
What's new with PHP7What's new with PHP7
What's new with PHP7
 
Jsphp 110312161301-phpapp02
Jsphp 110312161301-phpapp02Jsphp 110312161301-phpapp02
Jsphp 110312161301-phpapp02
 
DIG1108 Lesson 6
DIG1108 Lesson 6DIG1108 Lesson 6
DIG1108 Lesson 6
 

Recently uploaded

Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
Mariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceXMariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceX
Mariano Tinti
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
panagenda
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
KAMESHS29
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
SOFTTECHHUB
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Speck&Tech
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Safe Software
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
Neo4j
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
Claudio Di Ciccio
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
DianaGray10
 

Recently uploaded (20)

Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
Mariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceXMariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceX
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
 

PHP7 Presentation

  • 2. Table of contents ● Preamble ● PHP5.6: in case you missed something a. Overview b. New features ● PHP7: future is coming a. Overview b. What's new
  • 3. Preamble ● Use filter_var() // Check valid email bool filter_var('example@site.tld', FILTER_VALIDATE_EMAIL); // Remove empty values $data = array( 'value1' => '', 'value2' => null, 'value3' => [] ); filter_var_array($data); // return empty array ● Speed the code DON'T open/close PHP tags for excessive. DON'T use GLOBALS
  • 4. ● release date: August 2014 ● PHP5: last branch release PHP5.6: Overview
  • 5. PHP5.6: New features ● Constant expressions const ONE = 1; // Scalar Expression in constant const TWO = ONE * 2; ● Variadic functions/Argument unpacking function myTools($name, ...$tools) { echo "Name:". $name.'<br />'; echo "My Tool Count:". count(tools); } myTools('Avinash', 'Eclipse'); myTools('Avinash', 'Eclipse', 'Sublime'); myTools('Avinash', 'Eclipse', 'Sublime', 'PHPStorm'); function myTools($name, $tool1, $tool2, $tool3) { echo "Name:". $name.'<br />'; echo "Tool1:", $tool1.'<br />'; echo "Tool2:", $tool2.'<br />'; echo "Tool3:", $tool3; } $myTools = ['Eclipse', 'Sublime', 'PHPStorm']; myTools('Avinash', ...$myTools);
  • 6. PHP5.6: New features ● Exponentiation // PHP5.5 and before pow(2, 8); // 256 // PHP5.6 and after echo 2 ** 8; // 256 echo 2 ** 2 ** 4; // 256 ● use function and use const namespace NameSpace { const FOO = 42; function f() { echo __FUNCTION__."n"; } } namespace { use const NameSpaceFOO; use function NameSpacef; echo FOO."n"; f(); }
  • 7. PHP5.6: New features ● phpdbg: The interactive debugger http://phpdbg.com/docs ● php://input // Now deprecated $HTTP_RAW_POST_DATA // This is now reusable file_get_contents('php://input'); ● Large file uploads Files larger than 2 gigabytes in size are now accepted.
  • 8. PHP5.6: New features ● __debugInfo() 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) }
  • 9. ● Release date: October 2015 ● Engine: Zend v3 (32/64 bits) ● Performance: 25% to 70% faster ● Backward Incompatible Changes ● New Parser ● Tidy up old things ● Many new features PHP7: Overview
  • 10. ● Scalar Type Declarations // must be the first statement in a file. // If it appears anywhere else in the file it will generate a compiler error. declare(strict_types=1); // Available type hints int, float, string, bool // Examples function add(string $a, string $b): string { return $a + $b; } function add(int $a, int $b): int { return $a + $b; } function add(float $a, float $b): float { return $a + $b; } function add(bool $a, bool $b): bool { return $a + $b; } PHP7: What's new
  • 11. ● Group Use Declarations // PHP7 use FooLibraryBarBaz{ ClassA, ClassB, ClassC, ClassD as Fizbo }; // Before PHP7 use FooLibraryBarBazClassA; use FooLibraryBarBazClassB; use FooLibraryBarBazClassC; use FooLibraryBarBazClassD as Fizbo; ● switch.default.multiple Will raise E_COMPILE_ERROR when multiple default blocks are found in a switch statement. PHP7: What's new
  • 12. ● Alternative PHP tags removed <% // opening tag <%= // opening tag with echo %> // closing tag (<scripts+languages*=s*(php|"php"|'php')s*>)i // opening tag (</script>)i // closing tag ● Return Type Declarations // Returning array // Overriding a method that did not have a return type: function foo(): array { interface Comment {} return []; interface CommentsIterator extends Iterator { } function current(): Comment; } // Returning object interface A { static function make(): A; } class B implements A { static function make(): A { return new B(); } } PHP7: What's new
  • 13. ● Update json parser extension json extension has been replaced by jsond extension echo json_encode(10.0); // Output 10 echo json_encode(10.1); // Output 10.1 echo json_encode(10.0, JSON_PRESERVE_ZERO_FRACTION); // Output 10.0 echo json_encode(10.1, JSON_PRESERVE_ZERO_FRACTION); // Output 10.1 var_dump(json_decode(json_encode(10.0, JSON_PRESERVE_ZERO_FRACTION))); // Output double(10) var_dump(10.0 === json_decode(json_encode(10.0, JSON_PRESERVE_ZERO_FRACTION))); // Output bool(true) ● Removing old codes PHP4 constructor Removal of dead/unmaintained/deprecated SAPIs and extensions (imap, mcrypt, mysql, ereg, aolserver, isapi, ...) Remove the date.timezone warning PHP7: What's new
  • 14. ● new operators o Nullsafe Calls function f($o) { $o2 = $o->mayFail1(); if ($o2 === null) { return null; } $o3 = $o2->mayFail2(); if ($o3 === null) { return null; } $o4 = $o3->mayFail3(); if ($o4 === null) { return null; } return $o4->mayFail4(); } function f($o) { return $o?->mayFail1()?->mayFail2()?->mayFail3()?->mayFail4(); } PHP7: What's new
  • 15. ● new operators o Spaceship PHP7: What's new operator <=> equivalent $a < $b ($a <=> $b) === -1 $a <= $b ($a <=> $b) === -1 || ($a <=> $b) === 0 $a == $b ($a <=> $b) === 0 $a != $b ($a <=> $b) !== 0 $a >= $b ($a <=> $b) === 1 || ($a <=> $b) === 0 $a > $b ($a <=> $b) === 1
  • 16. ● new operators o Null Coalesce // Without null coalesce $username = isset($_GET['user']) ? $_GET['user'] : 'nobody'; // With null coalesce $username = $_GET['user'] ?? 'nobody'; PHP7: What's new
  • 17. ● Context Sensitive Lexer PHP7: What's new Newly reserved Now possible int Class::forEach() float Class::list() bool Class::for() string Class::and() true, false Class::or() null Class::new() Class::include() const CONTINUE
  • 18. ● Anonymous class support /* implementing an anonymous console object from your framework maybe */ (new class extends ConsoleProgram { public function main() { /* ... */ } })->bootstrap(); class Foo {} $child = new class extends Foo {}; var_dump($child instanceof Foo); // true // New Hotness $pusher->setLogger(new class { public function log($msg) { print_r($msg . "n"); } }); PHP7: What's new
  • 19. ● Uniform Variable Syntax // old meaning // new meaning $$foo['bar']['baz'] ${$foo['bar']['baz']} ($$foo)['bar']['baz'] $foo->$bar['baz'] $foo->{$bar['baz']} ($foo->$bar)['baz'] $foo->$bar['baz']() $foo->{$bar['baz']}() ($foo->$bar)['baz']() Foo::$bar['baz']() Foo::{$bar['baz']}() (Foo::$bar)['baz']() // Before global $$foo->bar; // Instead use global ${$foo->bar}; ● Unicode Codepoint Escape Syntax "U+202E" // String composed by U+ will now not be parsed as special characters echo "u{1F602}"; // outputs 😂 ● Instance class by reference not working anymore $class = &new Class(); // Will now return a Parse error PHP7: What's new
  • 20. ● Loop else foreach ($array as $x) { echo "Name: {$x->name}n"; } else { echo "No records found!n"; } ● Named Parameters // Using positional arguments: htmlspecialchars($string, double_encode => false); // Same as htmlspecialchars($string, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); // non changing default value htmlspecialchars($string, default, default, false); PHP7: Proposed features/In draft
  • 21. ● Union Types: multi types function (array|Traversable $in) { foreach ($in as $value) { echo $value, PHP_EOL; } } ● Enum types enum RenewalAction { Deny, Approve } function other(RenewalAction $action): RenewalAction { switch ($action) { case RenewalAction::Approve: return RenewalAction::Deny; case RenewalAction::Deny: return RenewalAction::Approve; } } PHP7: Proposed features/In draft
  • 22. PHPNG: Next Generation ● PHP8.0: 2020 ● PHP9.0: 2025
  • 23. PHP7: References ● PHP: rfc ● Etat des lieux et avenir de PHP ● En route pour PHP7