Home  >  Article  >  php教程  >  php中魔法常量_FILE_,_LINE_,__FUNCTION__用法

php中魔法常量_FILE_,_LINE_,__FUNCTION__用法

WBOY
WBOYOriginal
2016-06-13 10:04:001034browse

本文章主要是讲到了关于魔法常量_FILE_,_LINE_,__FUNCTION__,有需要的同学可以参考一下简单实用的一个实例。


名称
 描述
 
_FILE_
 当前文件名
 
_LINE_
 当前行号
 
_FUNCTION_
 当前函数名
 
_CLASS_
 当前类名
 
_METHOD_
 当前方法名

 

所谓的魔法常量,并不是真的常量,而是根据场合去获取固定值的变量

 代码如下 复制代码

echo __FILE__;

echo '
';
 

echo __LINE__;

echo '
';

 
function funcTest()

{

    echo __FUNCTION__;

}

funcTest();

?>
 

output

D:AppServwwwBasic7demo15.php
5
funcTest

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