Static variables and static methods of the PHP class

Why objects outside the class can access static methods, but not static variables

class Test
{
    public static $num = 100;
    public static function abc()
    {
        echo "";
    }
}
$t = new Test();
$t->abc();
// notice
echo $t->num;

Thank you for your help

Php
Apr.29,2021

The static member properties and static member methods of the

class are accessed through the class name:: [property name / method name] . The instantiated object of the class can be instantiated via self:: [property name / method name] .

as far as I understand it, static members are class, not object, so there is no way to access them through objects. If necessary, you can add the specified method to the object to modify it.


first of all, the document has a specific description of this point link
clipboard.png



echo $tvana

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e99961-1770.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e99961-1770.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?