我正在研究php/ajax函数。那个源代码对我来说是惊人的。但是该代码没有超链接功能。因此,我想从URL中从Q参数中进行超链接。
因此,我为此目的制作PHP代码。但是我很长一段时间都茫然。以下是我的php代码。
// Get the q parameter from URL
$q = $_REQUEST["q"];
$hint = "";
// Lookup all hints from array if $q is different from ""
if ($q !== "")
{
$q = strtolower($q);
$len = strlen($q);
foreach($a as $name)
{
if (stristr($q, substr($name, 0, $len)))
{
if ($hint === "")
{
$hint = $name;
echo '<a href="http://www.naver.com/"'$hint">" $hint"</a>";
}
else
{
$hint .= ", echo '<a href="http://www.naver.com/"'$hint">" $hint"</a>";
}
}
}
}
// Output "no suggestion" if no hint were found
// or output the correct values
echo $hint==="" ? "no suggestion" : $hint;
?>
如何制作href =" http://www ...超链接$ shint或$ name?
用它打印一个URL:
echo '< a href="http://www.naver.com/"'.$hint.">".$hint."< /a>";
$hint='< a href="http://www.naver.com/"'.$hint.">".$hint."< /a>";