ReflectionClass::hasMethod

(PHP 5 >= 5.1.2, PHP 7)

ReflectionClass::hasMethod锟斤拷榉斤拷锟斤拷欠锟斤拷讯锟斤拷锟�

说锟斤拷

public ReflectionClass::hasMethod ( string $name ) : bool

锟斤拷锟揭伙拷锟斤拷锟斤拷锟街革拷锟斤拷姆锟斤拷锟斤拷欠锟斤拷讯锟斤拷濉�

锟斤拷锟斤拷

name

要锟斤拷锟侥凤拷锟斤拷锟斤拷锟斤拷锟狡★拷

锟斤拷锟斤拷值

锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷 TRUE锟斤拷锟斤拷锟津返伙拷 FALSE锟斤拷

锟斤拷锟斤拷

Example #1 ReflectionClass::hasMethod() 锟斤拷锟斤拷

<?php
Class {
    public function 
publicFoo() {
        return 
true;
    }

    protected function 
protectedFoo() {
        return 
true;
    }

    private function 
privateFoo() {
        return 
true;
    }

    static function 
staticFoo() {
        return 
true;
    }
}

$rc = new ReflectionClass("C");

var_dump($rc->hasMethod('publicFoo'));

var_dump($rc->hasMethod('protectedFoo'));

var_dump($rc->hasMethod('privateFoo'));

var_dump($rc->hasMethod('staticFoo'));

// C should not have method bar
var_dump($rc->hasMethod('bar'));

// Method names are case insensitive
var_dump($rc->hasMethod('PUBLICfOO'));
?>

锟斤拷锟斤拷锟斤拷锟教伙拷锟斤拷锟斤拷锟�

bool(true)
bool(true)
bool(true)
bool(true)
bool(false)
bool(true)

锟轿硷拷