replyYou must define $name first like $xm before you can use $this->name;
__get and __set only need to be written 30 times. They will be automatically called when you access non-existent or private properties externally.
replyYou must define $name first like $xm before you can use $this->name; __get and __set only need to be written 30 times, and will be automatically called when you access non-existent or private properties externally.
Please modify the syntax in your class.
Also, your syntax for calling attributes of external objects is correct.
The magic method __get() you defined will only take effect when calling a property that does not exist in the class.
Add in front:
private $name ='';
Must be wrong, you have no definition
There is no $name in your class, how can you use $this->name
$this->$name 吧