Start · Sprachen · PHP · Referenz · property_exists

property_exists

Funktion

Prüft, ob ein Property definiert ist — auch wenn der Wert <code>null</code> ist.

seit PHP 5.1.0 Kategorie: oop

Signatur

property_exists(object|string $object_or_class, string $property): bool

Beschreibung

Anders als isset(): erkennt Properties auch mit null-Wert.

Parameter

Name Typ Default Beschreibung
$object_or_class Pflicht object|string Objekt/Klasse.
$property Pflicht string Property-Name.

Rückgabewert

Typ
bool

Beispiele

Basis

<?php

if (property_exists($obj, 'email')) $mail = $obj->email;