0

我有一个名为的文本文件database.txt,它包含 3 个用“-”分隔的 URL。

<?
$dir = $_POST['path123'];
$percorso = file($dir."/database.txt");
while(list(,$value) = each($percorso)){
list($gp1, $gp2, $gp3) = split("[:]", $value);
#declaration trim()
$params["gp1"] = trim($gp1);
$params["gp2"] = trim($gp2);
$params["gp3"] = trim($gp3);
#print results
}
echo '<img src="$gp1" border=0>';
?>

如您所见,path123是文件夹的名称,$percorso 是 database.txt 的路径。使用该代码,我应该在 3 个不同的变量(gp1、gp2 和 gp3)中加载 3 个 URL。

我的问题是,当我使用echo '<img src="$gp1" border=0>'mozilla 时,这里给我一个错误,上面写着“语法错误,意外 $end”。所以我无法在屏幕上显示我的 database.txt 文件中的第一个 URL。有什么帮助吗?

4

2 回答 2

3

改变

list($gp1, $gp2, $gp3) = split("[:]", $value); //will output http://

list($gp1, $gp2, $gp3) = split("[-]", $value); //will output http://linkhere.tld
于 2013-07-08T14:18:29.040 回答
2

改变

echo '<img src="$gp1" border=0>';

echo '<img src="'.$gp1.'" style="border: none;" />';
于 2013-07-08T14:13:32.953 回答