4 つの変数を持つクラスがあり、それらを文字列として個別に出力したいと考えています。(それらのそれぞれを異なる場所に印刷します)。
これはクラスの一部です。
class dash
{
public $name;
public $msg;
public $msg_date;
public $votes;
function __construct($name,$msg,$msg_date,$votes){
$this->name=$name;
$this->msg=$msg;
$this->msg_date=$msg_date;
$this->votes=$votes;}
public function __toString(){
return $this->name;
}
ここに印刷する必要があります:
function repliesView(){
$arr=objectsToArr();
$count=count($arr)-1;
for($i=0;$i<=$count;$count--){
echo "<p>name:$arr[$count]->name<br />";
echo "msg:$arr[$count]->msg<br />";
echo "date:arr[$count]->msg_date</p>";
}