# PHP Query DOMDocument::loadHTML(): Unexpected end tag : span in Entity ## 问题 在A环境上运行正常。但切换到b环境出现很多警告,如: ```php [warning] DOMDocument::loadHTML(): Unexpected end tag : span in Entity, line: 168 /vendor/jaeger/phpquery-single/phpQuery.php:328 [warning] DOMDocument::loadHTML(): Unexpected end tag : td in Entity, [warning] DOMDocument::loadHTML(): Unexpected end tag : b in Entity, line: 233 /vendor/jaeger/phpquery-single/phpQuery.php:328 [warning] DOMDocument::loadHTML(): error parsing attribute name in Entity, line: 523 /vendor/jaeger/phpquery-single/phpQuery.php:328 ``` 代码如下: ```php loadHTML($amazon); $doc->saveHTML(); $price = $doc -> getElementById('actualPriceValue')->textContent; $ASIN = $doc -> getElementById('ASIN')->getAttribute('value'); ?> ``` ## 解决 禁用警告,可以使用 ```php libxml_use_internal_errors(true); ``` ## 原因 正在加载无效的HTML。无效的HTML是很常见的,DOMDocument::loadHTML纠正了大多数问题,但默认情况下会发出警告。 使用libxml_use_internal_errors可以控制这种行为。在加载文档之前设置它: `libxml_use_internal_errors(true);` `$doc->loadHTML($amazon);`