is_object
Détecter si une variable est un objet
is_object()
vérifie si la variable est un objet.
Si la variable est un objet, la fonction renvoie true
(1), sinon false
/ NO RETOUR.
Vérifiez si la variable est un objet:
<? Php fonction get_cars ( $ obj ) { if ( ! is_object ( $ obj ) ) { retourne false ; } Retour $ obj -> voitures ; } $ obj = new stdclass ( ) ; $ Obj -> Cars = Array ( "Volvo" , "BMW" , "Audi" ) ; var_dump ( get_cars ( null ) ) ; écho "<br>" ; var_dump ( get_cars ( $ obj ) ) ; ?>
Essayez-le vous-même
is_object ( variable ) ;
paramètre | décrire |
---|---|
variable | Requis. Spécifie la variable à vérifier. |