Last active
December 1, 2019 11:01
-
-
Save jenovateurs/894067f9bbc24d0f85235aaef888b235 to your computer and use it in GitHub Desktop.
Nouveautés PHP 7.4 - Typage des propriété de classes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Utilisateur { | |
public int $nId; | |
public string $sNom; | |
} | |
$oUtilisateur = new Utilisateur(); | |
//Fonctionne | |
$oUtilisateur->nId = 1; | |
//Fatal error: Uncaught TypeError: Typed property Utilisateur::$id must be int, string used | |
$oUtilisateur->nId = 'Une erreur'; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment