Home > Backend Development > PHP Tutorial > Example analysis of magic constants in php

Example analysis of magic constants in php

黄舟
Release: 2023-03-16 20:00:02
Original
1118 people have browsed it

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();
Copy after login

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)
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template