CKTIS / PHP
method_exists()
Verifica se un metodo è definito, anche privato nella classe esaminata.
Versione: PHP 8.4; repository runtime, production runtime not attested
Sintassi
method_exists(object|string $object_or_class, string $method): boolVerifica se un metodo è definito, anche privato nella classe esaminata. Un risultato true non concede accesso. I nomi gestiti solo tramite __call non sono rilevati. Un nome di classe ignoto può attivare il caricamento automatico.
Firma
method_exists(object|string $object_or_class, string $method): bool
Output dell’esempio
[true,false,7]
Esempi
<?php
class Gauge { private function reset() {} public function __call($name,$args) { return 7; } }
$g=new Gauge(); echo json_encode([method_exists($g,"reset"),method_exists($g,"read"),$g->read()]);
Risultato
[true,false,7]