The private variable in the PHP class is redefined after initialization. The method in the class cannot get the value of the variable. Why?

problem description

defines a class with variable name in A, A. The name variable is defined by the _ _ set () method, and the method tell in A cannot take the value of name. This is why there is no way to go to the value of name
class A {

.
private $name;

public function __set($property,$value){
    $this->property = $value;
}

public function tell(){
    echo $this->name;
}

}

$a = new A ();
$a-> name= "Zhang San";
/ / call the tell () method, but $this- > name has no value
$a-> tell ();

Apr.12,2021

The assignment in

_ _ set () is written incorrectly, which is embarrassing

public function __set($property,$value){
    $this->$property = $value;   //   $this->property = $value;  
}

this you know _ _ set () Why don't you know _ _ get ()

now the code is equivalent to, you set the private property name, but the private property is not accessible outside the class

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-1e422e5-44992.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-1e422e5-44992.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?