SlideShare une entreprise Scribd logo
1  sur  15
Télécharger pour lire hors ligne
par Didier Sampaolo, consultant technique senior en freelance.
PHP 7.0
APERÇU DES NOUVEAUTÉS
Par /Didier SAMPAOLO @dsampaolo
PERFORMANCES
Mieux que PHP 5 et même mieux que HHVM
(Facebook)
Pré-analyse syntaxique: Abstract Syntax Tree
Vrai support 64 bits
PERFORMANCES : WORDPRESS
Crédits : Zend
Source : http://www.zend.com/en/resources/php7_infographic
PERFORMANCES : FRAMEWORKS
Crédits : Zend
Source : http://www.zend.com/en/resources/php7_infographic
LARAVEL FORGE
Pour les amoureux de Laravel Forge : PHP 7.0 est
maintenant la version installée par défaut sur vos nouveaux
Serveurs.
EXCEPTIONS
Les "Fatal Error" reculent au profit d'Exceptions.
Nouvelles exceptions :
ParseException
EngineException
Erreurs converties en exception :
E_ERROR
E_RECOVERABLE_ERROR
E_PARSE
E_COMPILE_ERROR
EXT/MYSQL
La vieille API "legacy" de MySQL
disparaît
Utilisez PDO !
DÉCLARATION DE TYPES SCALAIRES
Déjà en PHP 5 : classes, interfaces, tableaux, callable
Ajout des scalaires : bool, string, int, float
TYPAGE STRICT
Le mode Coercitif (par défaut) tentera une
conversion
Le mode Strict lèvera une exception
Comment passer en mode strict ?
declare(strict_types=1);
DÉCLARATION DE TYPES : EXEMPLE
function somme(int $a, int $b) {
        return $a + $b;
        }
        $total = somme(1, 2); // 3
        $total = somme('1', 2); // coercitif: 3 ('1' est converti en int)
        $total = somme('1', 2); // strict: EXCEPTION (Uncaught TypeError)
DÉCLARATION DE TYPES : RETURN
Le type renvoyé par une fonction peut aussi être défini !
function somme(int $a, int $b) : int {
    return $a + $b;
}
CLASSES ANONYMES
Même principe que les Fonctions anonymes (closures)
function createDog() {
    return new class {
        public function bark() {
            echo "WAF !";
        }
    };
}
$medor = createDog();
$medor­>bark(); // "WAF !"
OPÉRATEUR : NULL COALESCING
??
Avant PHP 7.0
echo (isset($first_name)) ? $first_name : 'Didier';
Après PHP 7.0
echo $first_name ?? 'Didier';
OPÉRATEUR : SPACESHIP
<=>
Comparaison ternaire :
$a et $b sont égaux,
ou $a est plus grand,
ou $b est plus
grand.
echo 12 <=> 17; // ­1 car $a < $b
echo 17 <=> 12; // 1 car $a > $b
echo 12 <=> 12; // 0 car $a == $b
MERCI !
Didier SAMPAOLO
Consultant technique senior freelance
- Ma société :
- Sur Twitter :
- à voir aussi :
Ca vous a plu ?
Didcode
@dsampaolo
Didlinks

Contenu connexe

Tendances

Formation PHP
Formation PHPFormation PHP
Formation PHPkemenaran
 
AlterWay SolutionsLinux Outils Industrialisation PHP
AlterWay SolutionsLinux Outils Industrialisation PHPAlterWay SolutionsLinux Outils Industrialisation PHP
AlterWay SolutionsLinux Outils Industrialisation PHPjulien pauli
 
La référence Clear php
La référence Clear phpLa référence Clear php
La référence Clear phpDamien Seguy
 
PHPTour 2011 - PHP5.4
PHPTour 2011 - PHP5.4PHPTour 2011 - PHP5.4
PHPTour 2011 - PHP5.4julien pauli
 
Patterns and OOP in PHP
Patterns and OOP in PHPPatterns and OOP in PHP
Patterns and OOP in PHPjulien pauli
 
Javascript ne se limite pas à jquery
Javascript ne se limite pas à jqueryJavascript ne se limite pas à jquery
Javascript ne se limite pas à jqueryneuros
 
PHP 5.3, PHP Next
PHP 5.3, PHP NextPHP 5.3, PHP Next
PHP 5.3, PHP NextSQLI
 
PHP #1 : introduction
PHP #1 : introductionPHP #1 : introduction
PHP #1 : introductionJean Michel
 
PHP 5.3 : les nouveautés du futur si proche
PHP 5.3 : les nouveautés du futur si prochePHP 5.3 : les nouveautés du futur si proche
PHP 5.3 : les nouveautés du futur si prochePascal MARTIN
 
Function oop - bonnes pratiques ms tech days
Function   oop - bonnes pratiques ms tech daysFunction   oop - bonnes pratiques ms tech days
Function oop - bonnes pratiques ms tech daysJean-Pierre Vincent
 
Php 7 Think php7
Php 7 Think php7Php 7 Think php7
Php 7 Think php7neuros
 

Tendances (18)

Formation PHP
Formation PHPFormation PHP
Formation PHP
 
AlterWay SolutionsLinux Outils Industrialisation PHP
AlterWay SolutionsLinux Outils Industrialisation PHPAlterWay SolutionsLinux Outils Industrialisation PHP
AlterWay SolutionsLinux Outils Industrialisation PHP
 
Cours php
Cours phpCours php
Cours php
 
La référence Clear php
La référence Clear phpLa référence Clear php
La référence Clear php
 
PHPTour 2011 - PHP5.4
PHPTour 2011 - PHP5.4PHPTour 2011 - PHP5.4
PHPTour 2011 - PHP5.4
 
PHP Training
PHP TrainingPHP Training
PHP Training
 
Patterns and OOP in PHP
Patterns and OOP in PHPPatterns and OOP in PHP
Patterns and OOP in PHP
 
Javascript ne se limite pas à jquery
Javascript ne se limite pas à jqueryJavascript ne se limite pas à jquery
Javascript ne se limite pas à jquery
 
Langage Perl
Langage PerlLangage Perl
Langage Perl
 
PHP 5.3, PHP Next
PHP 5.3, PHP NextPHP 5.3, PHP Next
PHP 5.3, PHP Next
 
PHP #1 : introduction
PHP #1 : introductionPHP #1 : introduction
PHP #1 : introduction
 
PHP 5.3 : les nouveautés du futur si proche
PHP 5.3 : les nouveautés du futur si prochePHP 5.3 : les nouveautés du futur si proche
PHP 5.3 : les nouveautés du futur si proche
 
Initiation au langage PHP
Initiation au langage PHPInitiation au langage PHP
Initiation au langage PHP
 
Function oop - bonnes pratiques ms tech days
Function   oop - bonnes pratiques ms tech daysFunction   oop - bonnes pratiques ms tech days
Function oop - bonnes pratiques ms tech days
 
cours Plsql _ abdelkhalek benhoumine
cours Plsql _ abdelkhalek benhouminecours Plsql _ abdelkhalek benhoumine
cours Plsql _ abdelkhalek benhoumine
 
Php seance1
Php seance1Php seance1
Php seance1
 
Php 7 Think php7
Php 7 Think php7Php 7 Think php7
Php 7 Think php7
 
Php cours
Php coursPhp cours
Php cours
 

En vedette

Laravel 5 New Features
Laravel 5 New FeaturesLaravel 5 New Features
Laravel 5 New FeaturesJoe Ferguson
 
Oracle University - Your Complete Training Source for Oracle Software and Har...
Oracle University - Your Complete Training Source for Oracle Software and Har...Oracle University - Your Complete Training Source for Oracle Software and Har...
Oracle University - Your Complete Training Source for Oracle Software and Har...ORACLE USER GROUP ESTONIA
 
MidwestPHP 2016 - Adventures in Laravel 5
MidwestPHP 2016 - Adventures in Laravel 5 MidwestPHP 2016 - Adventures in Laravel 5
MidwestPHP 2016 - Adventures in Laravel 5 Joe Ferguson
 
What's new in PHP 7.1
What's new in PHP 7.1What's new in PHP 7.1
What's new in PHP 7.1Simon Jones
 
Knowing Laravel 5 : The most popular PHP framework
Knowing Laravel 5 : The most popular PHP frameworkKnowing Laravel 5 : The most popular PHP framework
Knowing Laravel 5 : The most popular PHP frameworkBukhori Aqid
 
Introduction à Laravel 4 @Dogstudio
Introduction à Laravel 4 @DogstudioIntroduction à Laravel 4 @Dogstudio
Introduction à Laravel 4 @DogstudioNicolas Widart
 
Alphorm.com Java 8: les nouveautés
Alphorm.com Java 8: les nouveautésAlphorm.com Java 8: les nouveautés
Alphorm.com Java 8: les nouveautésAlphorm
 
Untitled presentation
Untitled presentationUntitled presentation
Untitled presentationskunk_anansie
 
CMSday 2013 - Doper votre audience en optimisant votre référencement ?
CMSday 2013 - Doper votre audience en optimisant votre référencement ?CMSday 2013 - Doper votre audience en optimisant votre référencement ?
CMSday 2013 - Doper votre audience en optimisant votre référencement ?Smile I.T is open
 
Peixos Abisals
Peixos AbisalsPeixos Abisals
Peixos Abisalscaranabito
 

En vedette (20)

Modern PHP
Modern PHPModern PHP
Modern PHP
 
PHP 7
PHP 7PHP 7
PHP 7
 
Laravel 5 New Features
Laravel 5 New FeaturesLaravel 5 New Features
Laravel 5 New Features
 
Laravel 5
Laravel 5Laravel 5
Laravel 5
 
Oracle University - Your Complete Training Source for Oracle Software and Har...
Oracle University - Your Complete Training Source for Oracle Software and Har...Oracle University - Your Complete Training Source for Oracle Software and Har...
Oracle University - Your Complete Training Source for Oracle Software and Har...
 
Laravel 5
Laravel 5Laravel 5
Laravel 5
 
MidwestPHP 2016 - Adventures in Laravel 5
MidwestPHP 2016 - Adventures in Laravel 5 MidwestPHP 2016 - Adventures in Laravel 5
MidwestPHP 2016 - Adventures in Laravel 5
 
Laravel 5 and SOLID
Laravel 5 and SOLIDLaravel 5 and SOLID
Laravel 5 and SOLID
 
What's new in PHP 7.1
What's new in PHP 7.1What's new in PHP 7.1
What's new in PHP 7.1
 
Knowing Laravel 5 : The most popular PHP framework
Knowing Laravel 5 : The most popular PHP frameworkKnowing Laravel 5 : The most popular PHP framework
Knowing Laravel 5 : The most popular PHP framework
 
Laravel 5
Laravel 5Laravel 5
Laravel 5
 
Introduction à Laravel 4 @Dogstudio
Introduction à Laravel 4 @DogstudioIntroduction à Laravel 4 @Dogstudio
Introduction à Laravel 4 @Dogstudio
 
Alphorm.com Java 8: les nouveautés
Alphorm.com Java 8: les nouveautésAlphorm.com Java 8: les nouveautés
Alphorm.com Java 8: les nouveautés
 
Javaoop
JavaoopJavaoop
Javaoop
 
Untitled presentation
Untitled presentationUntitled presentation
Untitled presentation
 
Pp2
Pp2Pp2
Pp2
 
2012 01-02 notasegw
2012 01-02 notasegw2012 01-02 notasegw
2012 01-02 notasegw
 
CMSday 2013 - Doper votre audience en optimisant votre référencement ?
CMSday 2013 - Doper votre audience en optimisant votre référencement ?CMSday 2013 - Doper votre audience en optimisant votre référencement ?
CMSday 2013 - Doper votre audience en optimisant votre référencement ?
 
Peixos Abisals
Peixos AbisalsPeixos Abisals
Peixos Abisals
 
Char
CharChar
Char
 

Similaire à PHP 7.0 : aperçu des nouveautés

Barcamp tunisie edition 2010 langage de programmation php
Barcamp tunisie edition 2010 langage de programmation php Barcamp tunisie edition 2010 langage de programmation php
Barcamp tunisie edition 2010 langage de programmation php Barcamp Tunisie
 
Présentation de PHP 5.4 [FR]
Présentation de PHP 5.4 [FR]Présentation de PHP 5.4 [FR]
Présentation de PHP 5.4 [FR]Wixiweb
 
Devoxx 2017 : toutes les actualités technologiques à surveiller !
Devoxx 2017 : toutes les actualités technologiques à surveiller !Devoxx 2017 : toutes les actualités technologiques à surveiller !
Devoxx 2017 : toutes les actualités technologiques à surveiller !Société ELOSI
 
Lbv Dev Meetup #1
Lbv Dev Meetup #1Lbv Dev Meetup #1
Lbv Dev Meetup #1LbvDev
 
hassclic270.ppt
hassclic270.ppthassclic270.ppt
hassclic270.pptadiouf2
 
Utilisation optimale et professionnelle de PHP
Utilisation optimale et professionnelle de PHPUtilisation optimale et professionnelle de PHP
Utilisation optimale et professionnelle de PHPJean-Marc Fontaine
 
Ecrire et déployer une appli PHP maintenable
Ecrire et déployer une appli PHP maintenableEcrire et déployer une appli PHP maintenable
Ecrire et déployer une appli PHP maintenableChristophe Villeneuve
 
Optimiser les performances dans Wordpress
Optimiser les performances dans WordpressOptimiser les performances dans Wordpress
Optimiser les performances dans WordpressNicolas Juen
 
PHPTour-2011-PHP_Extensions
PHPTour-2011-PHP_ExtensionsPHPTour-2011-PHP_Extensions
PHPTour-2011-PHP_Extensionsjulien pauli
 
M205developpemmetdigital123455555555.pdf
M205developpemmetdigital123455555555.pdfM205developpemmetdigital123455555555.pdf
M205developpemmetdigital123455555555.pdfmonirgrich
 
laravel.sillo.org-Cours Laravel 10 les bases installation et organisation.pdf
laravel.sillo.org-Cours Laravel 10  les bases  installation et organisation.pdflaravel.sillo.org-Cours Laravel 10  les bases  installation et organisation.pdf
laravel.sillo.org-Cours Laravel 10 les bases installation et organisation.pdfHeartKing10
 
Apache for développeurs PHP
Apache for développeurs PHPApache for développeurs PHP
Apache for développeurs PHPjulien pauli
 
AFUP & PHP @ Supelec
AFUP & PHP @ SupelecAFUP & PHP @ Supelec
AFUP & PHP @ Supelecjulien pauli
 
2008-09-30 Administration automatisée avec Powershell
2008-09-30 Administration automatisée avec Powershell2008-09-30 Administration automatisée avec Powershell
2008-09-30 Administration automatisée avec PowershellPatrick Guimonet
 

Similaire à PHP 7.0 : aperçu des nouveautés (20)

Barcamp tunisie edition 2010 langage de programmation php
Barcamp tunisie edition 2010 langage de programmation php Barcamp tunisie edition 2010 langage de programmation php
Barcamp tunisie edition 2010 langage de programmation php
 
Présentation de PHP 5.4 [FR]
Présentation de PHP 5.4 [FR]Présentation de PHP 5.4 [FR]
Présentation de PHP 5.4 [FR]
 
Devoxx 2017 : toutes les actualités technologiques à surveiller !
Devoxx 2017 : toutes les actualités technologiques à surveiller !Devoxx 2017 : toutes les actualités technologiques à surveiller !
Devoxx 2017 : toutes les actualités technologiques à surveiller !
 
Lbv Dev Meetup #1
Lbv Dev Meetup #1Lbv Dev Meetup #1
Lbv Dev Meetup #1
 
PHP, ce truc de vieux
PHP, ce truc de vieuxPHP, ce truc de vieux
PHP, ce truc de vieux
 
hassclic270.ppt
hassclic270.ppthassclic270.ppt
hassclic270.ppt
 
Utilisation optimale et professionnelle de PHP
Utilisation optimale et professionnelle de PHPUtilisation optimale et professionnelle de PHP
Utilisation optimale et professionnelle de PHP
 
Ecrire et déployer une appli PHP maintenable
Ecrire et déployer une appli PHP maintenableEcrire et déployer une appli PHP maintenable
Ecrire et déployer une appli PHP maintenable
 
Optimiser les performances dans Wordpress
Optimiser les performances dans WordpressOptimiser les performances dans Wordpress
Optimiser les performances dans Wordpress
 
PHPTour-2011-PHP_Extensions
PHPTour-2011-PHP_ExtensionsPHPTour-2011-PHP_Extensions
PHPTour-2011-PHP_Extensions
 
Formation php pdo
Formation php pdoFormation php pdo
Formation php pdo
 
Lp web tp3_idse
Lp web tp3_idseLp web tp3_idse
Lp web tp3_idse
 
43_pps.pdf
43_pps.pdf43_pps.pdf
43_pps.pdf
 
M205developpemmetdigital123455555555.pdf
M205developpemmetdigital123455555555.pdfM205developpemmetdigital123455555555.pdf
M205developpemmetdigital123455555555.pdf
 
Pdo
PdoPdo
Pdo
 
laravel.sillo.org-Cours Laravel 10 les bases installation et organisation.pdf
laravel.sillo.org-Cours Laravel 10  les bases  installation et organisation.pdflaravel.sillo.org-Cours Laravel 10  les bases  installation et organisation.pdf
laravel.sillo.org-Cours Laravel 10 les bases installation et organisation.pdf
 
Apache for développeurs PHP
Apache for développeurs PHPApache for développeurs PHP
Apache for développeurs PHP
 
AFUP & PHP @ Supelec
AFUP & PHP @ SupelecAFUP & PHP @ Supelec
AFUP & PHP @ Supelec
 
Xhprof
XhprofXhprof
Xhprof
 
2008-09-30 Administration automatisée avec Powershell
2008-09-30 Administration automatisée avec Powershell2008-09-30 Administration automatisée avec Powershell
2008-09-30 Administration automatisée avec Powershell
 

PHP 7.0 : aperçu des nouveautés

  • 2. PERFORMANCES Mieux que PHP 5 et même mieux que HHVM (Facebook) Pré-analyse syntaxique: Abstract Syntax Tree Vrai support 64 bits
  • 3. PERFORMANCES : WORDPRESS Crédits : Zend Source : http://www.zend.com/en/resources/php7_infographic
  • 4. PERFORMANCES : FRAMEWORKS Crédits : Zend Source : http://www.zend.com/en/resources/php7_infographic
  • 5. LARAVEL FORGE Pour les amoureux de Laravel Forge : PHP 7.0 est maintenant la version installée par défaut sur vos nouveaux Serveurs.
  • 6. EXCEPTIONS Les "Fatal Error" reculent au profit d'Exceptions. Nouvelles exceptions : ParseException EngineException Erreurs converties en exception : E_ERROR E_RECOVERABLE_ERROR E_PARSE E_COMPILE_ERROR
  • 7. EXT/MYSQL La vieille API "legacy" de MySQL disparaît Utilisez PDO !
  • 8. DÉCLARATION DE TYPES SCALAIRES Déjà en PHP 5 : classes, interfaces, tableaux, callable Ajout des scalaires : bool, string, int, float
  • 9. TYPAGE STRICT Le mode Coercitif (par défaut) tentera une conversion Le mode Strict lèvera une exception Comment passer en mode strict ? declare(strict_types=1);
  • 10. DÉCLARATION DE TYPES : EXEMPLE function somme(int $a, int $b) {         return $a + $b;         }         $total = somme(1, 2); // 3         $total = somme('1', 2); // coercitif: 3 ('1' est converti en int)         $total = somme('1', 2); // strict: EXCEPTION (Uncaught TypeError)
  • 11. DÉCLARATION DE TYPES : RETURN Le type renvoyé par une fonction peut aussi être défini ! function somme(int $a, int $b) : int {     return $a + $b; }
  • 12. CLASSES ANONYMES Même principe que les Fonctions anonymes (closures) function createDog() {     return new class {         public function bark() {             echo "WAF !";         }     }; } $medor = createDog(); $medor­>bark(); // "WAF !"
  • 13. OPÉRATEUR : NULL COALESCING ?? Avant PHP 7.0 echo (isset($first_name)) ? $first_name : 'Didier'; Après PHP 7.0 echo $first_name ?? 'Didier';
  • 14. OPÉRATEUR : SPACESHIP <=> Comparaison ternaire : $a et $b sont égaux, ou $a est plus grand, ou $b est plus grand. echo 12 <=> 17; // ­1 car $a < $b echo 17 <=> 12; // 1 car $a > $b echo 12 <=> 12; // 0 car $a == $b
  • 15. MERCI ! Didier SAMPAOLO Consultant technique senior freelance - Ma société : - Sur Twitter : - à voir aussi : Ca vous a plu ? Didcode @dsampaolo Didlinks