Php magic constant example introduction, php magic constant _ PHP Tutorial

Source: Internet
Author: User
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...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.