PHP/Reflection/method exists

Материал из Web эксперт
Перейти к: навигация, поиск

method_exists() function checks to see if a particular method, exists.

   <source lang="html4strict">

Its syntax is: bool method_exists (object obj_name, string method_name) <?

    class Car {
         var $fourWheel;
         function set() {
              $this->fourWeel = 1;
         }
    }
    $car = new Car;
    if (method_exists($car, "set")) :
         print "yes";
    else :
         print "no";
    endif;

?>

 </source>