Home > Article > Backend Development > PHP Magic Constants_PHP Tutorial
/****
****/
/***
====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();