我想让下面的代码工作,以便我明白我在做一个大型项目。大多数情况下,我只是试图确保我可以通过标签获取元素。该代码似乎打破了“$ html = new simple_html_dom();”因为如果我对此发表评论,那么我会得到两份打印件。但是如果没有注释掉,屏幕上什么也没有显示。PHP解析DOM与DOM
<?php
# create and load the HTML
include('simple_html_dom.php');
print "hello ";
$html = new simple_html_dom();
print "world"
#$html->load("<html><body><p>Hello World!</p><p>We're here</p></body></html>");
# get an element representing the second paragraph
#$element = $html->find("p");
# modify it
#$element[1]->innertext .= " and we're here to stay.";
# output it!
#echo $html->save();
?>
你应该真的设置'error_reporting(E_ALL)'进行开发。 –
而'ini_set('display_errors',true);'也是。 –
如果您看到空白页面,则表示在某处出现错误,并且您在浏览器中禁用了显示错误。 您可以使用AlexZ建议的'display_errors'或查看服务器日志。日志的位置取决于你的系统,但对于Linux来说,开始寻找的好地方是'/ var/log/apache2/error.log'。 – pwaring