Php magic constant test example
Directly paste the test code:
| The Code is as follows: |
|
|
Class MoShu {
Public function moshu (){
Echo 'current CLASS Name: '. _ CLASS _. "<br/> ";
Echo 'current Method Name: '. _ FUNCTION _. "<br/> ";
Echo 'the number of rows in the current file: '. _ LINE _. "<br/> ";
Echo 'absolute path of the current FILE: '. _ FILE _. "<br/> ";
Echo 'Folder of the absolute path of the current file: '. _ DIR _. "<br/> ";
Echo 'Return Class Name: METHOD Name: '. _ METHOD _. "<br/> ";
}
}
$ Moshu = new moshu ();
$ Moshu-> moshu ();
The result is as follows:
Current Class Name: MoShu
Current Method Name: moshu
Number of lines in the current file: 10
Absolute path of the current file: D: \ xampp \ htdocs \ test \ moshu. php
Folder in the absolute path of the current file: D: \ xampp \ htdocs \ test
Returned Class Name: Method Name: MoShu: moshu
Current Class Name: MoShu
Current Method Name: moshu
Number of lines in the current file: 10
Absolute path of the current file: D: \ xampp \ htdocs \ test \ moshu. php
Folder in the absolute path of the current file: D: \ xampp \ htdocs \ test
Returned Class Name: Method Name: MoShu: moshu |