Signatur
method_exists(object|string $object_or_class, string $method): bool
Beschreibung
Ideal für Duck-Typing. Für Sichtbarkeitsprüfung: ReflectionMethod.
Parameter
| Name | Typ | Default | Beschreibung |
|---|---|---|---|
| $object_or_class Pflicht | object|string | — | Objekt oder Klasse. |
| $method Pflicht | string | — | Methode. |
Rückgabewert
Typ
bool
Beispiele
Basis
<?php
if (method_exists($obj, 'toArray')) $data = $obj->toArray();