How to check whether a method is static in PHP?

萝らか妹 提交于 2019-12-12 08:39:56

问题


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.


回答1:


use ReflectionMethod::isStatic




回答2:


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

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


来源:https://stackoverflow.com/questions/7513589/how-to-check-whether-a-method-is-static-in-php

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!