PHP简单的HTML DOM解析器[致命错误调用非对象上的成员函数find()]

时间:2014-11-02 23:57:54

标签: php html dom get

有谁知道为什么我有这个错误?我做错了什么?

<?
include('simple_html_dom.php');

$html = ("http://99designs.pt/logo-design/contests?show=finished");
foreach($html->find('span[class=active.sl_notranslate]') as $aholder) {

echo $aholder . '<br>';
}
?>
  

致命错误:在非对象中调用成员函数find()   第5行的../simplehtml.php

1 个答案:

答案 0 :(得分:1)

您忘记添加函数名称file_get_html,代码应如下所示:

<?php
  include 'simple_html_dom.php';

  $html = file_get_html("http://99designs.pt/logo-design/contests?show=finished");
  foreach($html->find('span[class=active.sl_notranslate]') as $aholder) {

    echo $aholder . '<br>';
  }

?>