Detailed Explanation of Magic Constants in PHP
- 2021-08-12 02:17:30
- OfStack
Detailed Explanation of Magic Constants in PHP
This paper introduces the magic constants in php programming. Mastering and flexibly applying these methods and constants is of great help to improve the programming level of php. Friends in need refer to study.
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();
Running 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)
If you have any questions, please leave a message or go to this site community to exchange and discuss, thank you for reading, hope to help everyone, thank you for your support to this site!