您好我使用此代码在指定的目录上查找文件。这有效,但我希望当我点击resoutt时它会在新标签页中打开
代码是:
<?php
$dir = 'ups';
$exclude = array('.','..','.htaccess');
$q = (isset($_GET['q']))? strtolower($_GET['q']) : '';
$res = opendir($dir);
while(false!== ($file = readdir($res))) {
if(strpos(strtolower($file),$q)!== false &&!in_array($file,$exclude)) {
echo "<a href='$dir/$file'>$file</a>";
echo "<br>";
}
}
closedir($res);
?>
当我使用
时<?php
echo "<a href='$dir/$file'>$file target = "_blank"</a>";
?>
这表明:
Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/u688698883/public_html/search/ss.php on line 8
答案 0 :(得分:0)
<a href = "something.php" target = "_blank">
根据用户偏好打开一个新标签/窗口。请在发布前搜索。
Open link in new tab or window
在你的情况下:
<?php
echo "<a href='$dir/$file' target = '_blank'>$file</a>";
?>