Javascript 如何修改gethint的PHP代码?

Javascript 如何修改gethint的PHP代码?,javascript,php,ajax,Javascript,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 = strtolo

我正在学习英语。源代码对我来说太棒了。但该代码没有超链接功能。因此,我想从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;
?>
//从URL获取q参数
$q=$_请求[“q”];
$hint=“”;
//如果$q与“”不同,则从数组中查找所有提示
如果($q!==“”)
{
$q=strtolower($q);
$len=strlen($q);
foreach($a作为$name)
{
if(stristr($q,substr($name,0,$len)))
{
如果($hint==“”)
{
$hint=$name;
回声';
}
其他的
{
$hint.=“,echo'”;
}
}
}
}
//如果未找到任何提示,则输出“无建议”
//或输出正确的值
echo$hint==“”?“无建议”:$hint;
?>

我如何制作a href=”http://www... 超级链接$hint或$name?

使用此链接打印URL:

echo '< a href="http://www.naver.com/"'.$hint.">".$hint."< /a>"; 
$hint='< a href="http://www.naver.com/"'.$hint.">".$hint."< /a>";
echo'“$hint.””;
$hint='“$hint.””;

不要使用w3schools,请查看此链接了解更多信息。我非常感谢您的友好编码。