PHP Magic Constant Example Introduction, PHP Magic constant _php Tutorial

Source: Internet
Author: User

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 ...

  • 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.