array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'de', ), 'this' => array ( 0 => 'function.is-object.php', 1 => 'is_object', ), 'up' => array ( 0 => 'ref.var.php', 1 => 'Funktionen zur Behandlung von Variablen', ), 'prev' => array ( 0 => 'function.is-numeric.php', 1 => 'is_numeric', ), 'next' => array ( 0 => 'function.is-real.php', 1 => 'is_real', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'de', 'path' => 'reference/var/functions/is-object.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 4, PHP 5, PHP 7, PHP 8)
is_object — Prüft, ob eine Variable vom Typ object ist
value
Die zu untersuchende Variable.
Version | Beschreibung |
---|---|
7.2.0 |
is_object() liefert nun true für unserialisierte
Objekte ohne Klassendefinition (Klasse
__PHP_Incomplete_Class) zurück. Zuvor wurde
false zurückgeliefert.
|
Beispiel #1 is_object()-Beispiel
<?php
// Eine einfache Funktion deklarieren, die ein Array unseres Objekts zurückgibt
function get_students($obj)
{
if (!is_object($obj)) {
return false;
}
return $obj->students;
}
// Deklarieren einer neuen Instanz der Klasse und Befüllen mit Werten
$obj = new stdClass();
$obj->students = array('Kalle', 'Ross', 'Felipe');
var_dump(get_students(null));
var_dump(get_students($obj));
?>