简体   繁体   English

PHP带有打印或回显的href链接

[英]PHP a href link with print or echo

I have quick question about a herf link in php field. 我对php字段中的herf链接有快速疑问。 When I try to make a href link in php field by using echo or print, it does not work the link. 当我尝试通过使用echo或print在php字段中创建href链接时,该链接不起作用。 Could you see the code briefly? 您能简短地看一下代码吗? Thanks! 谢谢!

if(isset($_SESSION["manager"])){
    echo "<div id=\"login_link\">
            Welcome Admin!<br>
            <a herf=\"storeAdmin/admin_logout.php\">Log out</a>
            </div>"; 
    }

It should be href="...." not "herf". 它应该是href =“ ....”而不是“ herf”。

For more info about the a tag you can take a look here: http://www.w3schools.com/tags/tag_a.asp 有关a标签的更多信息,请参见此处: http : //www.w3schools.com/tags/tag_a.asp

Here I have updated your code 在这里,我已经更新了您的代码

if(isset($_SESSION["manager"])){
        echo '<div id=\"login_link\">
                Welcome Admin!<br>
                <a href=\"storeAdmin/admin_logout.php\">Log out</a>
                </div>'; 
        }
  1. It is href="" not herf="" 它是href=""而不是herf=""
  2. It is good practice to refrain from using relative links, as it is likely to cause issues in more complex sites. 最好不要使用相对链接,因为它可能会在更复杂的站点中引起问题。 Use something like href="/root-path-to-your-stuff/storeAdmin/admin_logout.php" 使用类似href="/root-path-to-your-stuff/storeAdmin/admin_logout.php"

也只是一个建议,您可以随时使用“内部”,而不必取消报价。Atleast对我有用

Had the same problem but its because I was using 有同样的问题,但是因为我在用

echo "".htmlspecialchars($errorMessage).""; 回声“” .htmlspecialchars($ errorMessage)。“”;

removing the htmlspecialchars fixed it for me. 删除htmlspecialchars为我修复了它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM