Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/242.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
php中指向局部变量的返回函数_Php_Variables_Methods_Return - Fatal编程技术网

php中指向局部变量的返回函数

php中指向局部变量的返回函数,php,variables,methods,return,Php,Variables,Methods,Return,谢谢如果您使用$this->$name它实际上会在$this中查找名为$name的属性。因此,在您的示例中,$this->$name将查找$this->Omer如果您使用$this->$name它将实际查找$this中名为$name的属性。因此,在您的示例中,$this->$name将查找$this->Omer来说明@Aaron如此雄辩地回答了什么,下面将编译: class Person{ var $name = "Omer"; function get_name(){

谢谢

如果您使用
$this->$name
它实际上会在
$this
中查找名为
$name
的属性。因此,在您的示例中,
$this->$name
将查找
$this->Omer
如果您使用
$this->$name
它将实际查找
$this
中名为
$name
的属性。因此,在您的示例中,
$this->$name
将查找
$this->Omer

来说明@Aaron如此雄辩地回答了什么,下面将编译:

class Person{

     var $name = "Omer";

     function get_name(){
         return $this->name;//Why not $this->$name ?
     }
}

为了说明@Aaron如此雄辩地回答了什么,下面将编译:

class Person{

     var $name = "Omer";

     function get_name(){
         return $this->name;//Why not $this->$name ?
     }
}