Portál AbcLinuxu, 15. července 2025 22:49
return method_exists(__CLASS__,$method);ale taky to nefunguje
class Test {
public function maMetodu($name) {
return method_exists($this,$name);
}
// V pripade statickeho kontextu misto $this pouzit self
}
A ta funkce bere dva parametry aby byla dost obecná...
Pokud ta class neexistuje, nezbyde než ji vytvořit.
return method_exists($this, $method);A pokud ne, tak s největší pravděpodobností něco děláš špatně.
<?php class Test { static function maMetodu($method) { return method_exists(__CLASS__,$method); } } echo "aa: ",Test::maMetodu('aa'),"\n"; echo "maMetodu: ",Test::maMetodu('maMetodu'),"\n";
Tiskni
Sdílej:
ISSN 1214-1267, (c) 1999-2007 Stickfish s.r.o.