大佬教程收集整理的这篇文章主要介绍了php – 检查扩展类中是否存在方法,但不检查父类,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
class Toot { function Good() {} } class Tootsie extends Toot { function Bad() {} } function testMethodExists() { // true var_dump(method_exists('Toot','Good')); // false var_dump(method_exists('Toot','Bad')); // true var_dump(method_exists('Tootsie','Good')); // true var_dump(method_exists('Tootsie','Bad')); }
class A { function a() { /* ... */} function b() { /* ... */} } class B extends A { function b() { /* ... */} function c() { /* ... */} } function own_method($class_name,$method_Name) { if (method_exists($class_name,$method_Name)) { $parent_class = get_parent_class($class_Name); if ($parent_class !== falsE) return !method_exists($parent_class,$method_Name); return true; } else return false; } var_dump(own_method('B','a')); // false var_dump(own_method('B','b')); // false var_dump(own_method('B','c')); // true
以上是大佬教程为你收集整理的php – 检查扩展类中是否存在方法,但不检查父类全部内容,希望文章能够帮你解决php – 检查扩展类中是否存在方法,但不检查父类所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。