我有控制器
<?php
class Onetimescan extends CI_Controller{
public function index() {
#LOAD -->>>> LIB ###########
$this->load->library('session'); ## LOAD LIBS: SESSION
$this->load->helper('simpledom');
#LOAD -->>>> MODEL
$this->load->model('scanmodel');
$this->scanmodel->loadurlbasedonsessid($this->session->userdata('session_id')); // echo out inserted domain in loadurlbasedonsessid() func
$sss= $this->session->userdata('tld'); // echo $sss;
$siteToSearch = file_get_html($sss);
foreach($siteToSearch->find('form') as $element){
echo "<h1 style='color:red; '>".$element->action."</h1> <br />";
}
}
}
?>我在这行中得到了Call to a member function find() on a non-object的致命错误:
foreach($siteToSearch->find('form') as $element){simpledom是我在顶部加载的一个助手(实际上称为simpledom_helper.php),它的file_get_html定义如下:
[http://pastebin.com/HaJtKfNb][1]我在这里做错什么了?我尝试过像public function file_get_html{}那样定义函数,但这会导致错误。
我修正了这一切,增加了:
$prefix = "http://www.";
//echo "SSS is: ".$sss;
$siteToSearch = file_get_html($prefix.$sss);FIXED>> url试图使用get_file_contents(somedomain.com),并将http://www.作为一个完全合格的域丢失。这个函数get_file_contents似乎需要http://www.
发布于 2013-02-02 01:19:54
助手函数应该像这样调用,因为它们不是对象:
$this->load->helper('simpledom');
$siteToSearch = file_get_html($sss);https://stackoverflow.com/questions/14657563
复制相似问题