Usage of magic constants _FILE_,_LINE_,__FUNCTION__ in php_PHP tutorial

WBOY
Release: 2016-07-13 16:59:55
Original
917 people have browsed it

This article mainly talks about the magic constants _FILE_, _LINE_, __FUNCTION__. Students in need can refer to a simple and practical example.


Name
Description

_FILE_
Current file name

_LINE_
Current line number

_FUNCTION_
Current function name

_CLASS_
Current class name

_METHOD_
Current method name

The so-called magic constants are not real constants, but variables that obtain fixed values ​​according to the situation

The code is as follows
 代码如下 复制代码

echo __FILE__;

echo '
';
 

echo __LINE__;

echo '
';

 
function funcTest()

{

    echo __FUNCTION__;

}

funcTest();

?>
 

output

D:AppServwwwBasic7demo15.php
5
funcTest

Copy code
echo __FILE__;

echo __LINE__; echo '
'; function funcTest() {
echo __FUNCTION__; }
funcTest(); ?> output D:AppServwwwBasic7demo15.php 5 funcTest http://www.bkjia.com/PHPjc/631294.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/631294.htmlTechArticleThis article mainly talks about the magic constants _FILE_, _LINE_, __FUNCTION__. Students in need can refer to the simple A practical example. Name Description _FILE_ Current file name _LI...
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template