redeclare file_get_html simple_html_dom.php

时间:2012-12-08 17:37:38

标签: php simple-html-dom simpledom

我使用简单的html dom来解析itunes预览页面

当我把URL放在代码[download] url [/ download]中时,一切都好,但当我有2个或更多[download] url [/ download]代码时我收到错误

致命错误:无法在第80行的/var/.../simple_html_dom.php中重新声明file_get_html()(之前在/var/.../simple_html_dom.php:65中声明)

function download_link($link){
$file=ROOT_DIR."/engine/data/obmennik.php";
include '/var/.../simple_html_dom.php'; //ПАРСИНГ
require($file);
$site=parse_url($link);
$domain=$site['host'];
$itunes = file_get_html($link); //ПАРС
$image = $itunes->find('img.artwork[width=175]',0); //ПАРС
$e = $itunes->find("div.price", 0);
$u = $itunes->find("h1", 0);
$star = $itunes->find("div.rating", 0);
$un = $itunes->find("div.fat-binary-blurb", 0);
$dt=date('Y-m-d [H:00]');

if(array_key_exists($domain,$link_arr)){
       $link="\n".'<br><a title="Скачать файл c '.$domain.'" rel="nofollow" target="_blank" href="http://li.ru/go?'.$link.'"><div style="-webkit-border-radius: 8px;-moz-border-radius: 8px;border-radius: 8px;background: #DCDCDC;"><table><tr><td width="35%"><img class="its_small" src=\"'.$image->src.'\"  /></td><td width="65%" valign="middle" align="center"><span  style="font-size:16px; font-weight: bold;"> '.iconv("UTF-8","cp1251",$u->plaintext). '<br> [iTunes Link, '.iconv("UTF-8","cp1251",$e->plaintext).']</span><br><br>'.iconv("UTF-8","cp1251",$un->outertext).'<br>Рейтинг на: '.$dt.' '.$star->outertext.'</td></tr></table></div></a>';

} return $link; }

function decode_base64($code){
$code="[download]".trim(base64_decode($code))."[/download]";
return $code;
$itunes->clear();
}

1 个答案:

答案 0 :(得分:6)

将您的include更改为include_once。这是因为您要包含两次相同的文件 - 每次包含它时,您都声明file_get_html函数。

修改:您可能希望对以下行中的require执行相同操作,将其更改为require_once