php - Two Instances of Simple HTML Dom -
i using php include source 2 files onto web page.
the 2 different files 1.php , 2.php have 2 different instances using simplehtmldom.
the issue 2.php when included onto web page, shows following error in position.
fatal error: cannot redeclare file_get_html() (previously declared in /home/northsho/public_html/w/pages/simple_html_dom.php:70) in /home/northsho/public_html/w/pages/simple_html_dom.php on line 85
edit:
further clarification.
master.php (includes 1.php , 2.php)
1.php , 2.php both use simple_html_dom.php
use structure, although without including 2 files , moving contents function , passing url parameter
master.php
<?php include 'simple_html_dom.php'; include '1.php'; include '2.php';
1.php
<?php $html = file_get_html('http://example.domain.com'); //do job //destroy object @ end $html->clear(); unset($html);
2.php
<?php $html = file_get_html('http://anotherexample.domain.com'); //do job //destroy object @ end $html->clear(); unset($html);
master.php using function instead of including 2 other files
<?php include 'simple_html_dom.php'; function domyjob($url){ $html = file_get_html($url); //do actual job $result = $html->plaintext; $html->clear(); unset($html); return $result; } //call function print domyjob("http://example.com");
Comments
Post a Comment