2

シンプルなhtml domを使用してiTunesプレビューページを解析しています

コード [download]url[/download] に URL を入力するとすべて問題なく動作しますが、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();
}
4

1 に答える 1

8

に変更includeしますinclude_once。これは、同じファイルを 2 回インクルードしているためです。インクルードするたびに、file_get_html関数を宣言しています。

編集require:おそらく、次の行で同じことをしたいと思うでしょう。require_once

于 2012-12-08T17:41:28.207 に答える