PHP 数组中缩写标签的问题.仅显示到第一个空格


issues with abbr tag in php array. only shows until first space

我正在尝试将 abbr 标签合并到我的 php 数组中,以便当机场的缩写(例如 MSP 或 AMS)出现时,当您将鼠标悬停在它上面时,它将显示机场的全名。

我使用的代码是:

echo "    <td width='70' bgcolor='$row_color'><img src='../flags/".$row['countryflag']."'>   
&nbsp;&nbsp;<abbr title=".$row['luchthavennaam'].">".$row['luchthavencode']."</abbr></td>";

它会一直显示我,直到它名称中的第一个空格,然后切断它。当我在 Toad 中运行查询时,我确实看到全名显示出来,所以这与我的工作方式有关。

有什么想法吗?

添加引号:<abbr title='"". htmlspecialchars($row['luchthavennaam'])."'">

就个人而言,我更喜欢在 php 中使用单引号

echo '<td width="70" bgcolor="'.$row_color.'"><img src="../flags/'.$row['countryflag'].'">   
&nbsp;&nbsp;<abbr title="'.$row['luchthavennaam'].'">'.$row['luchthavencode'].'</abbr></td>';

试试这个:

echo "<td width='70' bgcolor='$row_color'><img src='../flags/".$row['countryflag']."'>   
&nbsp;&nbsp;<abbr title='".$row['luchthavennaam']."'>".$row['luchthavencode']."</abbr>   </td>";

标题中缺少单引号。

通知

title='".$row['luchthavennaam']."'

而不是

title=".$row['luchthavennaam']." .