定义和用法

如果 method_name的方法在 object 所指的对象类中定义则返回 TRUE 否则返回 FALSE.

 

语法

bool  method_exists(object object,string method_name)

参数解释:

 object :对象

 method_name :方法名数据

 

返回值

将返回一个bool值。

 

例子

 
  
  1. class index{  
  2.  
  3.  function init(){  
  4.  
  5.  echo "start";  
  6.  
  7.  }  
  8.  
  9. }  
  10.  
  11. $ss = new index();  
  12.  
  13. if (method_exists($ss, init)) {  
  14.  
  15.  $ss->init();  
  16.  }else{  
  17.  
  18.  echo "Action does not exist";  
  19.  
  20. }