如何检查domdocument是否有项目
代码:
$iframe = $dom->getElementsByTagName('iframe');
foreach ($iframe as $if) {
//how to check whether $if has items for
// $if->item(0) so that I can access it without errors?
}
如何检查domdocument是否有项目
代码:
$iframe = $dom->getElementsByTagName('iframe');
foreach ($iframe as $if) {
//how to check whether $if has items for
// $if->item(0) so that I can access it without errors?
}
测试节点是否有子节点hasChildNodes()
foreach ($iframe as $if) {
if ($if->hasChildNodes()) {
// first child is $if->childNodes->item(0)
}
}
你可以检查使用喜欢
if($if -> hasChildNodes()) { ... }