Home » Php » How to check whether a method is static in PHP?

How to check whether a method is static in PHP?

Posted by: admin July 12, 2020 Leave a comment

Questions:

I need to know whether the method is declared as static given its name and the name of the class containing it. method_exists provides true for both static and non-static methods.

How to&Answers:

use ReflectionMethod::isStatic

Answer:

Here’s a little more clear way on how to use ReflectionMethod:

$MethodChecker = new ReflectionMethod($ClassName,$MethodName);
var_dump($MethodChecker->isStatic());