Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does php check whether the method of a class exists

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article is about how php checks for the existence of methods of a class. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

In PHP, you can use the method_exists () function to check whether the class's method exists in the specified object, with the syntax "method_exists ($object,$method_name)"; if so, return true, otherwise return false.

Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer

Php checks for the existence of methods in the class. You can use the method_exists () function.

Method_exists-checks whether the method of the class exists, and that the method of the class exists in the specified object.

Syntax:

Method_exists ($object,$method_name)

Parameters:

Object: object example or class name.

Method_name: method name.

Return value: returns true if the method referred to by method_name is defined in the object class referred to by object, otherwise it returns false.

Example:

Output result:

Bool (true) Thank you for your reading! This is the end of this article on "how to check the existence of class methods in php". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report