The code should be correct, what's going on?
比你盖茨
比你盖茨 2017-07-24 16:13:01
0
6
1512

QQ截图20170724161159.jpg22.jpg

比你盖茨
比你盖茨

reply all(6)
Peter_Zhu
public function __get($name)
{
    return $this -> $name; //$name是外部传参,属于变量
}

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.


nearest

Add in front:

private $name = "yourname";


phpcn_u11553

private $name ='';

mr

Must be wrong, you have no definition

Ailon

There is no $name in your class, how can you use $this->name

  • reply If this is the case, then each of the 30 fields must be __get __set 30 times?
    比你盖茨 author 2017-07-25 11:20:04
  • reply You 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.
    Ailon author 2017-07-25 11:31:52
  • reply You 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.
    Ailon author 2017-07-25 11:32:10
Pequeño

    $this->$name 吧

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template