Home  >  Article  >  Backend Development  >  Example analysis of magic constants in php

Example analysis of magic constants in php

黄舟
黄舟Original
2017-10-28 09:19:131095browse

Detailed explanation of examples of Magic constants in PHP

This article introduces the magic constants in phpProgramming, master them and Flexible application of these methods and constants will be of great help in improving PHP programming level. Friends in need can refer to it.

Magic constant:

namespace ns1; 
class Test { 
  function construct() { 
    var_dump(LINE); 
    var_dump(FILE); 
    var_dump(DIR); 
    var_dump(FUNCTION); 
    var_dump(CLASS); 
    var_dump(METHOD); 
    var_dump(NAMESPACE); 
  } 
} 
new Test();

Run result

int 5
string 'E:\wamp\www\a.php' (length=17)
string 'E:\wamp\www' (length=11)
string 'construct' (length=11)
string 'ns1\Test' (length=8)
string 'ns1\Test::construct' (length=21)
string 'ns1' (length=3)

The above is the detailed content of Example analysis of magic constants in php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn