我正在使用簡單的HTML DOM解析器庫來解析帶有DOCTYPE標記的URL。我能夠達到所需的標籤,但每當我回應或嘗試存儲結果時,它都不會顯示任何內容。但是,var_dump()顯示我需要的字符串。Var_dump()顯示String,echo()/ print_r()返回Nothing
require_once("simpledom.php");
$url="http://google.com";
$sPage = file_get_contents($url);
$sPageContent = new simple_html_dom();
$sPageContent->load($sPage);
$sObjects = $sPageContent->find('unknown');
foreach($sObjects as $sKey)
{
var_dump($sKey->_[4]); /*this var_dump shows the stuff */
$showres = $sKey->_[4]
}
/* this variable should hold the string but it shows nothing */
echo $showres;
什麼類型的var_dump顯示你? – PeterPan666
var_dump顯示了字符串'<!doctype html>'(length = 15) –
您是否試圖在循環內回顯,就像您在做var_dump一樣? –