Home > Article > Backend Development > Example analysis of magic constants in php
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!