SlideShare une entreprise Scribd logo
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

PDF
Nouveautés php 7
PDF
PHP 7 et Symfony 3
PPT
Introduction au langage PHP (1ere partie) élaborée par Marouan OMEZZINE
ODP
Migration PHP4-PHP5
PDF
Communications Réseaux et HTTP avec PHP
PPT
Introduction au langage PHP (2éme partie) élaborée par Marouan OMEZZINE
PPT
PHP - get started
PDF
PHP 1 - Apprendre les bases
Nouveautés php 7
PHP 7 et Symfony 3
Introduction au langage PHP (1ere partie) élaborée par Marouan OMEZZINE
Migration PHP4-PHP5
Communications Réseaux et HTTP avec PHP
Introduction au langage PHP (2éme partie) élaborée par Marouan OMEZZINE
PHP - get started
PHP 1 - Apprendre les bases

Tendances (18)

ODP
Formation PHP
PDF
AlterWay SolutionsLinux Outils Industrialisation PHP
PPT
Cours php
PDF
La référence Clear php
PDF
PHPTour 2011 - PHP5.4
PPTX
PHP Training
ODP
Patterns and OOP in PHP
PDF
Javascript ne se limite pas à jquery
PPTX
Langage Perl
PPT
PHP 5.3, PHP Next
PDF
PHP #1 : introduction
PDF
PHP 5.3 : les nouveautés du futur si proche
PPTX
Initiation au langage PHP
PDF
Function oop - bonnes pratiques ms tech days
PDF
cours Plsql _ abdelkhalek benhoumine
PDF
Php seance1
PDF
Php 7 Think php7
PPT
Php cours
Formation PHP
AlterWay SolutionsLinux Outils Industrialisation PHP
Cours php
La référence Clear php
PHPTour 2011 - PHP5.4
PHP Training
Patterns and OOP in PHP
Javascript ne se limite pas à jquery
Langage Perl
PHP 5.3, PHP Next
PHP #1 : introduction
PHP 5.3 : les nouveautés du futur si proche
Initiation au langage PHP
Function oop - bonnes pratiques ms tech days
cours Plsql _ abdelkhalek benhoumine
Php seance1
Php 7 Think php7
Php cours
Publicité

En vedette (20)

PDF
Modern PHP
PDF
Laravel 5 New Features
PDF
Laravel 5
PDF
Oracle University - Your Complete Training Source for Oracle Software and Har...
PDF
Laravel 5
PDF
MidwestPHP 2016 - Adventures in Laravel 5
PPTX
Laravel 5 and SOLID
PDF
What's new in PHP 7.1
PDF
Knowing Laravel 5 : The most popular PHP framework
PPTX
Laravel 5
PDF
Introduction à Laravel 4 @Dogstudio
PDF
Alphorm.com Java 8: les nouveautés
PPTX
Javaoop
PPT
Untitled presentation
PPT
CMSday 2013 - Doper votre audience en optimisant votre référencement ?
PPT
Peixos Abisals
PPTX
Modern PHP
Laravel 5 New Features
Laravel 5
Oracle University - Your Complete Training Source for Oracle Software and Har...
Laravel 5
MidwestPHP 2016 - Adventures in Laravel 5
Laravel 5 and SOLID
What's new in PHP 7.1
Knowing Laravel 5 : The most popular PHP framework
Laravel 5
Introduction à Laravel 4 @Dogstudio
Alphorm.com Java 8: les nouveautés
Javaoop
Untitled presentation
CMSday 2013 - Doper votre audience en optimisant votre référencement ?
Peixos Abisals
Publicité

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

PPT
Barcamp tunisie edition 2010 langage de programmation php
ODP
Présentation de PHP 5.4 [FR]
PPTX
Devoxx 2017 : toutes les actualités technologiques à surveiller !
PDF
Lbv Dev Meetup #1
PPTX
PHP, ce truc de vieux
PPT
hassclic270.ppt
PDF
Utilisation optimale et professionnelle de PHP
PDF
Ecrire et déployer une appli PHP maintenable
PPTX
Optimiser les performances dans Wordpress
PDF
PHPTour-2011-PHP_Extensions
PPT
Formation php pdo
PDF
Lp web tp3_idse
PDF
43_pps.pdf
PPT
Presentation d'une Formation du language avencer php.ppt
PDF
M205developpemmetdigital123455555555.pdf
PDF
PDF
laravel.sillo.org-Cours Laravel 10 les bases installation et organisation.pdf
PDF
Apache for développeurs PHP
PDF
AFUP & PHP @ Supelec
PPTX
WC Bretagne 2024 - Tester son extension avec les outils WordPress
Barcamp tunisie edition 2010 langage de programmation php
Présentation de PHP 5.4 [FR]
Devoxx 2017 : toutes les actualités technologiques à surveiller !
Lbv Dev Meetup #1
PHP, ce truc de vieux
hassclic270.ppt
Utilisation optimale et professionnelle de PHP
Ecrire et déployer une appli PHP maintenable
Optimiser les performances dans Wordpress
PHPTour-2011-PHP_Extensions
Formation php pdo
Lp web tp3_idse
43_pps.pdf
Presentation d'une Formation du language avencer php.ppt
M205developpemmetdigital123455555555.pdf
laravel.sillo.org-Cours Laravel 10 les bases installation et organisation.pdf
Apache for développeurs PHP
AFUP & PHP @ Supelec
WC Bretagne 2024 - Tester son extension avec les outils WordPress

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