Home >php教程 >php手册 >PHP的__METHOD__魔术常量用法

PHP的__METHOD__魔术常量用法

WBOY
WBOYOriginal
2016-05-25 16:47:331344browse

本文章来简单的介绍METHOD的用法,这在php5之后才会有的魔术常量,有需要的朋友可参考.

__METHOD__ 是PHP5之后新增的魔术常量,表示的是类文法的名称

实例代码如下:

<?php
class chhua {
    function test() {
        echo __METHOD__;
    }
}
$e = new chhua();
$e->test(); //输出:chhua::test
?>

还有更多的此类函数,如有__isset(), __unset(), __sleep(), __wakeup(), __toString(), __invoke(),

__set_state() and __clone()这里就不介绍了大家可百度搜索.


教程链接:

随意转载~但请保留教程地址★

Statement:
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