PHP Magic Constants Examples introduced, PHP Magic constants
The Magic constant PHP provides a lot of predefined constants to any script it runs, and our usual PHP magic constants are __class__ __function__ __line__ __file__ __dir__ __method__, This article introduces PHP Magic constants to you through examples of PHP
Instance:
Classpublicfunction Moshu () { echo__class__ . "
"; Echo __function__ . "
"; Echo __line__ . "
"; Echo __file__ . "
"; Echo ' folder where the current file is located in the absolute path: '. __dir__. "
"; Echo __method__ . "
"; }} $moshu New Moshu (); $moshu->moshu ();
Copy the code here to run a
The results are as follows:
Current class Name: Moshu Current method Name: Moshu the number of lines in the current file: the Absolute path of the current file: D: \xampp\htdocs\test\moshu. The folder of the absolute path where the current file of PHP is located: D:\xampp\htdocs\test Returns the class name :: Method Name: Moshu::moshu
http://www.bkjia.com/PHPjc/1102842.html www.bkjia.com true http://www.bkjia.com/PHPjc/1102842.html techarticle PHP Magic Constant Instance introduction, PHP Magic constant Magic constant PHP to it run any script provides a lot of predefined constants, we commonly used PHP magic constant has __class__ __functi ...