Home  >  Article  >  Backend Development  >  PHP Magic Constants_PHP Tutorial

PHP Magic Constants_PHP Tutorial

WBOY
WBOYOriginal
2016-07-14 10:06:48722browse

/****
 ****/


/***
====Notes Section====
Magic Constant

1: Its value cannot be modified manually, so it is called a constant
2: But the value changes with the environment, so it’s called magic

---Magic constants
__FILE__ Returns the path of the current file.
In framework development or website initialization script, it is used to calculate the root directory of the website

__LINE__ Returns the current line number
In the framework, it can be used to record error information during debugging



__CLASS__ returns the current class name

__METHOD__ returns the current method name
***/


echo 'What is currently running is',__FILE__,'file','
';

echo 'Currently in the',__DIR__,' directory
';

echo 'hi,I'm here',__LINE__,'line
';
echo 'hello, I'm here',__LINE__,'line
';
echo 'hehe,I'm',__LINE__,'line
';


class Human {
Public static function t() {
echo 'You are running',__CLASS__,'Class
';
echo 'under',__METHOD__,'method';
}  
}

Human::t();

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/477907.htmlTechArticle?php /**** ****/ /*** ====Notes Section==== Magic constant 1: Its value cannot be modified manually, so it is called constant 2: But the value changes with the environment, so it is called magic---magic constant __FILE__ Return...
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