SlideShare una empresa de Scribd logo
1 de 23
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

Más contenido relacionado

La actualidad más candente

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
 
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 PHPGuilherme 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 - OdW13julien 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] 2015Colin O'Dell
 
Introducing PHP Latest Updates
Introducing PHP Latest UpdatesIntroducing PHP Latest Updates
Introducing PHP Latest UpdatesIftekhar 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.5Wim 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.5Tom 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 mojobpmedley
 
Codeigniter4の比較と検証
Codeigniter4の比較と検証Codeigniter4の比較と検証
Codeigniter4の比較と検証ME iBotch
 
Understanding PHP objects
Understanding PHP objectsUnderstanding PHP objects
Understanding PHP objectsjulien pauli
 
Quick tour of PHP from inside
Quick tour of PHP from insideQuick tour of PHP from inside
Quick tour of PHP from insidejulien pauli
 
Perl web frameworks
Perl web frameworksPerl web frameworks
Perl web frameworksdiego_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 PHPBradley Holt
 
web2py:Web development like a boss
web2py:Web development like a bossweb2py:Web development like a boss
web2py:Web development like a bossFrancisco Ribeiro
 
Php 7 hhvm and co
Php 7 hhvm and coPhp 7 hhvm and co
Php 7 hhvm and coPierre Joye
 

La actualidad más candente (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 a New PHP version 1.2 introduces PHP5.6 and PHP7 features

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 OutFerenc Kovács
 
PHP 8: Process & Fixing Insanity
PHP 8: Process & Fixing InsanityPHP 8: Process & Fixing Insanity
PHP 8: Process & Fixing InsanityGeorgePeterBanyard
 
Giới thiệu PHP 7
Giới thiệu PHP 7Giới thiệu PHP 7
Giới thiệu PHP 7ZendVN
 
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.pdfWPWeb Infotech
 
Getting started with TDD - Confoo 2014
Getting started with TDD - Confoo 2014Getting started with TDD - Confoo 2014
Getting started with TDD - Confoo 2014Eric 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 VeronaPatrick Allaert
 
Living With Legacy Code
Living With Legacy CodeLiving With Legacy Code
Living With Legacy CodeRowan 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
 
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
 
JavaScript for PHP developers
JavaScript for PHP developersJavaScript for PHP developers
JavaScript for PHP developersStoyan Stefanov
 
PHP 5.3 Overview
PHP 5.3 OverviewPHP 5.3 Overview
PHP 5.3 Overviewjsmith92
 
Dependency injection in Drupal 8
Dependency injection in Drupal 8Dependency injection in Drupal 8
Dependency injection in Drupal 8Alexei Gorobets
 
Jsphp 110312161301-phpapp02
Jsphp 110312161301-phpapp02Jsphp 110312161301-phpapp02
Jsphp 110312161301-phpapp02Seri Moth
 

Similar a New PHP version 1.2 introduces PHP5.6 and PHP7 features (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
 

Último

Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Scott Andery
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 

Último (20)

Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 

New PHP version 1.2 introduces PHP5.6 and PHP7 features

  • 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