Home >Backend Development >PHP Tutorial >PHP的魔术常量__METHOD__简介_php技巧

PHP的魔术常量__METHOD__简介_php技巧

WBOY
WBOYOriginal
2016-05-17 08:39:241166browse

__METHOD__ 是PHP5之后新增的魔术常量,表示的是类文法的名称。魔术常量是一种PHP预定义常量,它的值可以是变化的,PHP中的其它已经存在的魔术常量有__LINE__、__FILE__、__FUNCTION__、__CLASS__等。

下面就用一小段代码来演示一下__METHOD__的用法。

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

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