PHP Doku:: Checks if instantiable - reflectionclass.isinstantiable.html

Verlauf / Chronik / History: (2) anzeigen

Sie sind hier:
Doku-StartseitePHP-HandbuchFunktionsreferenzVariablen- und typbezogene ErweiterungenReflectionThe ReflectionClass classReflectionClass::isInstantiable

Ein Service von Reinhard Neidl - Webprogrammierung.

The ReflectionClass class

<<ReflectionClass::isInstance

ReflectionClass::isInterface>>

ReflectionClass::isInstantiable

(PHP 5)

ReflectionClass::isInstantiableChecks if instantiable

Beschreibung

public bool ReflectionClass::isInstantiable ( void )

Checks if the class is instanciable.

Warnung

Diese Funktion ist bis jetzt nicht dokumentiert. Es steht nur die Liste der Argumente zur Verfügung.

Parameter-Liste

Diese Funktion hat keine Parameter.

Rückgabewerte

Gibt bei Erfolg TRUE zurück. Im Fehlerfall wird FALSE zurückgegeben.

Beispiele

Beispiel #1 ReflectionClass::isInstantiable() example

<?php
class { }

interface 
iface {
    function 
f1();
}

class 
ifaceImpl implements iface {
    function 
f1() {}
}

abstract class 
abstractClass {
    function 
f1() { }
    abstract function 
f2();
}

class 
extends abstractClass {
    function 
f2() { }
}

$classes = array("C""iface""ifaceImpl""abstractClass""D");

foreach(
$classes  as $class ) {
    
$reflectionClass = new ReflectionClass($class);
    echo 
"Is $class instantiable?  ";
    
var_dump($reflectionClass->IsInstantiable()); 
}

?>

Das oben gezeigte Beispiel erzeugt folgende Ausgabe:

Is C instantiable?  bool(true)
Is iface instantiable?  bool(false)
Is ifaceImpl instantiable?  bool(true)
Is abstractClass instantiable?  bool(false)
Is D instantiable?  bool(true)

Siehe auch


Keine BenutzerBeiträge.
- Beiträge aktualisieren...



PHP Powered Diese Seite bei php.net
The PHP manual text and comments are covered by the Creative Commons Attribution 3.0 License © the PHP Documentation Group - Impressum - mail("TO:Reinhard Neidl",...)