我正在使用简单的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一样? –