Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/290.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 提取数据失败,出现错误“;对非对象调用成员函数find();_Php_Parsing - Fatal编程技术网

Php 提取数据失败,出现错误“;对非对象调用成员函数find();

Php 提取数据失败,出现错误“;对非对象调用成员函数find();,php,parsing,Php,Parsing,为什么这个代码不起作用?我仍然收到此错误: 对中的非对象调用成员函数find() 尝试使用var_dump查看函数调用的结果 很可能php.ini配置禁止您获取外部数据。有关此操作的详细信息,请查看phpinfo()。要查看的属性是'allow\u url\u fopen'file\u get\u html()失败。你需要弄清楚原因。 <?php header('Content-type: text/plain; charset=utf-8'); include('simple_html

为什么这个代码不起作用?我仍然收到此错误:

对中的非对象调用成员函数find()


尝试使用var_dump查看函数调用的结果

很可能php.ini配置禁止您获取外部数据。有关此操作的详细信息,请查看phpinfo()。要查看的属性是'allow\u url\u fopen'

file\u get\u html()
失败。你需要弄清楚原因。
<?php
header('Content-type: text/plain; charset=utf-8');

include('simple_html_dom.php');
$html = file_get_html('http://www.test.com/');

// Find all links 
foreach($html->find('a') as $element) {
  echo $element->href . '<br>';
}

?>