【发布时间】:2019-09-10 22:26:33
【问题描述】:
我使用file_get_html 的这段代码从 php 中的 html 文件中回显一个 tah。
但是在本地运行我的代码后出现错误。
错误:
致命错误:未捕获的错误:调用 C:\xampp\htdocs\2\index.php:2 中未定义的函数 file_get_html() 堆栈跟踪:#0 {main} 在 C:\xampp\htdocs\2\ 中抛出第 2 行的 index.php
php 代码:
<?php
$html = file_get_html('http://example.com/');
// Find all images
foreach($html->find('img') as $element);
echo $element->src . '<br>';
// Find all links
foreach($html->find('a') as $element);
echo $element->href . '<br>';
?>
这是更改后的错误:
警告:file_get_contents():流不支持在 C:\xampp\htdocs\2\simple_html_dom.php 中的第 75 行查找
警告:file_get_contents():未能在第 75 行 C:\xampp\htdocs\2\simple_html_dom.php 中的流中定位 -1
致命错误:未捕获的错误:在 C:\xampp\htdocs\2\index.php:7 中调用布尔值上的成员函数 find() 堆栈跟踪:#0 {main} 在 C:\xampp\htdocs 中抛出\2\index.php 在第 7 行
【问题讨论】: