php - A value is obviously assigned to variable A, but it is assigned to variable B. Why?
学习ing
学习ing 2017-06-17 09:15:14
0
1
644

code show as below:

<?php
namespace Controller\Ip;
 
 class IpController{
     public $ip;
     public $key;
     public function Run(){
         $this->$ip = '111';
         $this->$key = '222';
         echo $this->$ip; //输出:222
     }

Why is the final output $this->$key? Looking for a solution, and I hope you can explain it, thank you very much

学习ing
学习ing

reply all(1)
淡淡烟草味
<?php
namespace Controller\Ip;
 
 class IpController{
     public $ip;
     public $key;
     public function Run(){
         $this->ip = '111';
         $this->key = '222';
         echo $this->ip;
     }
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template