Reputation: 26101
Here are three methods function_one
, function_two
and function_three
in Example
class.
class Example
{
private function function_one() { ... }
protected function function_two() { ... }
public function function_three() { ... }
public function check_here()
{
if (is_public_method('function_three')) {
return true;
} else {
return false;
}
}
}
So, I want to know which Access Modifier (public
, protected
, private
) is the method. The imaginary is_public_method
should return true because function_three
is public
method. Is there way to do this?
Upvotes: 0
Views: 141
Reputation: 2441
You need to be looking at ReflectionMethod's isPublic method.
Upvotes: 1
Reputation:
You can do this using ReflectionClass
and ReflectionMethod
:
public function check_here()
{
$obj = new ReflectionClass($this);
return $obj->getMethod('function_three')->isPublic();
}
Upvotes: 2