我需要在另一个选项卡的 echo 语句中打开一个文件

I need to open a file in an echo statement in another tab

当我单击 php 回显语句中的 link 时,文件在页面本身中打开。我希望文件在另一个选项卡中打开。

我知道需要使用target="_blank",但是如何在我的代码中输入它:

echo <div align=center><a href='$files_show'>$files_field</a></div>";

尝试添加空白目标

echo "<div align=center><a href=\"$files_show\" target=\"_blank\">$files_field</a></div>";
echo "<div align=center><a href='".$files_show."' target='_blank'>$files_field</a></div>";

The target attribute specifies where the linked document will open when the link is clicked. The default is the current window. If target="_blank", the linked document will open in a new tab or (on older browsers) a new window. Source

您应该使用单引号和双引号在锚 link 中使用 php 变量,如下所示。

echo "<div align='center'><a href='".$files_show."' target='_blank'>".$files_field."</a></div>";

您需要 <a> 属性 target="_blank"

此属性根据浏览器设置在新选项卡或新 window 中打开 link。

echo '<div align="center"><a href="'. $files_show .'" target="_blank">' . $files_field .'</a></div>';