所以現在有兩件事情我被困住了。第一個php類和數組至少對我來說是瘋狂的
class DisplayTaxonomy {
public $MyArray[]= new DisplayTaxonomy(); //the compiler says syntax error
//things I have tried
//public $ss[]= new Object();
}
第二!在這樣的功能:
public function whatever()
{
$Temp = new DisplayTaxonomy();
$Temp->setADTitle("1");
$MyArray[]= $Temp;//works just fine.
//then i tried to return the array
return $MyArray[];
}
我得到以下 //不能用[],用於讀取C:\ XAMPP \ htdocs中\ WordPress的\ WP - //內容\主題\ twentyeleven \ page.php文件上線52 然後在客戶端
$y=new DisplayTaxonomy();
$myArray[]=new DisplayTaxonomy();//works fine dont know why I cant do this in theclass.
$myArray[]=$y->getArrayOfDisplayTaxonomyObjects();
echo $myArray[0]->getADTitle();
我建議你一次只問一個問題,那就是這個網站的效果最好。當然,你可以同時提出兩個問題(如果你還需要的話)。 – hakre 2012-07-18 21:05:34
到目前爲止所有答案的一般性評論。在構造函數中使用'new'語句的所有解決方案都會引發報警! – markus 2012-07-18 21:09:04