Introduction to the Magic Constant __METHOD__ of PHP
- 2021-07-07 06:49:56
- OfStack
__METHOD__ is a magic constant added after PHP5 and represents the name of the class grammar. Magic Constant is a predefined PHP constant whose value can be variable. Other existing magic constants in PHP are __LINE__, __FILE__, __FUNCTION__, __CLASS__, etc.
The following is a short code to demonstrate the use of __METHOD__ under 1.
<?php
class chhua{
function test(){
echo __METHOD__;
}
}
$e=new chhua();
$e->test();// Output: chhua::test