Example of php magic constants: php magic constants. Php magic constant example introduction, php magic constant php provides a lot of predefined constants to any script it runs, common php magic constants include _ CLASS____FUNCTI php magic constants.
The Magic constant php provides a large number of predefined constants to any scripts it runs, common php magic constants include _ CLASS _ FUNCTION _ LINE _ FILE _ DIR _ METHOD, this article introduces php magic constants through php instances.
Instance:
Class MoShu {public function moshu () {echo 'current CLASS name: '. _ class __."
"; Echo 'current method name: '. _ FUNCTION __."
"; Echo 'The number of rows in the current file: '. _ LINE __."
"; Echo 'absolute path of the current FILE: '. _ FILE __."
"; Echo 'folder of the absolute path of the current file: '. _ DIR __."
"; Echo 'return class name: METHOD name: '. _ METHOD __."
";}}$ Moshu = new moshu (); $ moshu-> moshu ();
Copy the code here and run one
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: D: \ xampp \ htdocs \ test. the returned class name is MoShu: moshu.
The secret magic constant php provides a large number of predefined constants to any scripts it runs. our common php magic constants include _ CLASS _ FUNCTI...