php method_exists 检测类中是否包括函数
Jun 02, 2016 am 09:14 AM
method_exists
php method_exists 检测类中是否包括函数.
method_exists() 函数的语法如下:bool method_exists(object object,string method_name).
method_exists() 函数的作用是检查类的方法是否存在,如果 method_name 所指的方法在 object 所指的对象类中已定义,则返回 true,否则返回 false,实例代码如下:
class a { public function xx(){ echo 'xx'; } public function yy() { echo 'yy'; } } $obj = new a(); var_dump(method_exists($obj, 'xx')); var_dump(method_exists($obj, 'xx')); var_dump(method_exists($obj, 'xx')); //测试结果都为true class a { public function xx(){ echo 'xx'; } public function yy() { echo 'yy'; } public function yy() { echo 'yy'; } } $obj = new a(); $obj->yy(); $obj->yy();
Copy after login
以上语句报错,今天才发现原来php的对象属性是不区分大小写的.
本文地址:
转载随意,但请附上文章地址:-)
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article
How Long Does It Take To Beat Split Fiction?
3 weeks ago
By DDD
Repo: How To Revive Teammates
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌

Hot tools Tags

Hot Article
How Long Does It Take To Beat Split Fiction?
3 weeks ago
By DDD
Repo: How To Revive Teammates
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)
