Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
大家好,我正在为 XPath 查询苦苦挣扎,我希望查询在没有发现任何内容时返回“0”值。到目前为止,这是我的代码:
$query = $xpathvar->query('//DataStatistics/report'); foreach($query as $result){ echo "$result->length";
它现在只是返回空白,任何建议将不胜感激?
您必须获取$query自身的长度(如果没有length,则循环永远不会运行):
$query
length
$query = $xpathvar->query('//DataStatistics/report'); echo $query->length;