草庐IT

34567808765098767

全部标签

php - unset() 在类方法中不起作用

我有一个类Foo,它有一个名为bar的json字符串属性:[PHPFiddleLink]bar);}publicfunctionremove($timestamp){$newBar=$this->getBar();print_r($newBar);unset($newBar[$timestamp]);print_r($newBar);$this->bar=json_encode($newBar);}}现在,要从栏中删除一个元素,我正在执行以下操作,我不明白为什么它没有删除:$foo=newFoo();$foo->remove("1455261541");echo$foo->bar;打印