2011-11-30 64 views
0

我有一個對象陣列$this->result給定一個對象數組,如何回顯內容?

當我回聲$this->result我得到Array

當我print_r($this->result)我得到一個空白屏幕。

如何查找存儲在此對象數組中的內容?

編輯:通過空白屏幕我的意思是什麼都沒有呈現。

EDIT2: 下面是呈現的代碼,但我不知道它在做什麼。

<?php 
    foreach ($this->result as $r){ 
     extract($r); 
     // Then there is a bunch of code beneath here 
     // that displays different results 
    } 
?> 

但如果我這樣做,頁面不再呈現在所有。

echo '<pre>' . print_r($this->result, true) . '</pre>'; 

    foreach ($this->result as $r){ 
     extract($r); 
     // Then there is a bunch of code beneath here 
     // that displays different results 
    } 

EDIT3:

安裝並打開了XDebug後,var_dump現在顯示的數據。 (但print_r()仍然沒有)。任何想法,爲什麼這可能是?

+0

嘗試的var_dump($這個 - >結果) – Jemaclus

+0

@Jemaclus:不,還是踢出一個空白屏幕。 – kylex

+1

向我們顯示您正在使用的代碼。你忘了';'? – Galen

回答

1

如果可用,說實話我會使用一個php調試器,如xdebug,並建立一個調試客戶端,並檢查它。不知道數組中對象內容的原因是什麼?

print_r設置爲true時將返回輸出而不是將其打印到屏幕上。

怎麼樣

foreach ($this->result as $r){ 
    print_r($r); 
} 
+0

xdebug確實允許var_dump現在顯示,但它爲什麼不顯示它自己? – kylex

+0

xdebug爲php增加了更好的堆棧跟蹤信息。回頭看,var_dump似乎適用於對象。你可以發佈var_dump的輸出,也許這與數組中的對象有關嗎? –

+0

只是編碼別的東西,你也應該看看反射api.http://php.net/manual/en/book.reflection.php –

4
echo '<pre>' . print_r($this->result, true) . '</pre>'; 

More reading material —參見 「回報」 的說法。

+0

有趣的想法,但仍然沒有去。只要我嘗試回顯或打印或返回結果,屏幕不會呈現。 (在瀏覽器中查看源代碼時根本沒有代碼)。 – kylex

相關問題