如何在回显的html链接中写回声

-2 html php if-statement echo

好的,我试图创建一个导航链接,可以将用户带到那里的个人资料页面.我创建了一个函数"find_user_by_id($ user_id)"用于......嗯...通过id找到用户.我需要的是弄清楚如果用户当前在那里的配置文件页面如何使用它,它显示"注销"链接,其中通常放置"配置文件"链接.唯一的问题是,我不知道如何在已经回显的标签内进行Echo .下面的代码可能会帮助您了解更多:urlencode($user["id"])<a href>

if ($accessPage =='profile') {
        echo "<a href=\"logout.php\">Logout</a>";
    } else {
        echo "<a href=\"profile.php?id=<?php echo urlencode($user["id"]); ?>\">Profile</a>";
    }
Run Code Online (Sandbox Code Playgroud)

sen*_*rio 5

你只需要连接.

if ($accessPage == 'profile') {
    echo "<a href=\"logout.php\">Logout</a>";
} else {
    echo "<a href=\"profile.php?id=" .
         urlencode($user["id"]) .
         " \">Profile</a>";
}
Run Code Online (Sandbox Code Playgroud)


tan*_*tan 5

你不需要另一个回声,只需使用连接字符串.操作者

echo "<a href=\"profile.php?id=". urlencode($user["id"]) . "\">Profile</a>";
Run Code Online (Sandbox Code Playgroud)