作者热门文章
- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
当我第二次尝试在 dom 对象中加载文件时(我之前清除了它),dom 变量为空:(如何在类里面使用两次 simple-html-dom 类?
<?php
require_once 'simple_html_dom.php';
class RO{
public $dom;
public $dom2;
public function __construct(){
$this->dom = new simple_html_dom();
$this->dom2 = new simple_html_dom();
}
function GetDatumInUroPodatkovInTabKrajev($lang){
$this->dom->load_file("http://www...diferentadresthenbelow...html");
$tabelaTempInKrajev = $this->dom->find('table[@class="online"]');
//some code...
//some code...
return $this->functon2("minkjaaa");
}
function functon2($ik){
$this->dom2->load_file("http://www.arso.gov.si/vreme/napovedi%20in%20podatki/vreme_si.html");
$tabelaVremRazm = $this->dom2->find('table[@class="online"]'); // this line trows an error, becaus dom2 is empty
return"";
}
}
?>
和 trowen 错误:[ fatal error :在线调用 C:\..\simple_html_dom.php 中非对象的成员函数 find() ..]
最佳答案
Find("SELECTORS", index)
Find 返回一个对象数组,除非指定了可选索引,否则它将返回第 N 个对象...这可能是您所缺少的。 .. 这是一个工作示例:
// includes Simple HTML DOM Parser
include "simple_html_dom.php";
$url = "http://www.arso.gov.si/vreme/napovedi%20in%20podatki/vreme_si.html";
//Create a DOM object
$dom2 = new simple_html_dom();
// Load HTML from a string
$dom2->load_file($url);
// Find the link with the appropriate selectors
$table = $dom2->find('table.online', 0);
// Find succeeded
if ($table)
echo $table->outertext;
else
echo "Find function failed !";
// Clear DOM object (needed essentially when using many)
$dom2->clear();
unset($dom2);
关于php - 无法在一个类中加载两次 simple-html-dom 类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19539998/
我正在开发一个需要能够平均三个数字的 Facebook 应用程序。但是,它总是返回 0 作为答案。这是我的代码: $y = 100; $n = 250; $m = 300; $number = ($y
我只是无法弄清楚这一点,也找不到任何对我来说有意义的类似问题。我的问题:我从数据库中提取记录,并在我的网页上以每个面板 12 条的倍数显示它们。因此,我需要知道有多少个面板可以使用 JavaScrip
我是一名优秀的程序员,十分优秀!