我徘徊爲什麼這不會將數組值添加到對象。將值添加到對象內的屬性。
<pre>
<?php
class people_names{
public $children_names = ["hanna", "danny", "toddy"];
public $teen_names = ["shewit", "rahel", "elizabeth"];
public $old_people_names = ["douglas", "bob", "michael"];
}
$names = new people_names;
$children = $name->children_names[] = "ninja";
var_dump($name->children_names);
當然,必須有添加一個名字$children_name
我試圖$children = $name->children_names[] = "ninja";
和$children = $name->children_names = "ninja";
的方式,但沒有得到補充,忍者。
這可能是什麼問題和解決方案?