簡體   English   中英

不能在 PHP echo 語句中放置超鏈接

[英]Can't put hyperlink in PHP echo statement

在下面的代碼中,我在 echo 語句中添加了<a href=\"member.php\"></a> 但是,當我在 PHP 中添加任何超鏈接時,會出現語法錯誤。 我在這里缺少什么嗎? 謝謝你。

if ($username==$dbusername && $password==$dbpassword)
                {
                    echo "You're in!  <a href=\"member.php\"><!--I'm getting the sytax error in the hyper link here.-->Click here</a> to enter the member area";
                    }

                    else                
                        echo "Incorrect username/password";
                        }

                        else
                            die('That user does not exist');
                            }

    else
        die('Please enter a username/password');

    ?>

更新

更新了轉義標簽。

您需要轉義您的報價:

echo "You're in! <a href=\"member.php\">Hello!</a>";

那是因為您在字符串介紹HTML 屬性中都使用了雙引號。 您不能混合它們並期望它們正常工作。

您有兩個選擇 - 轉義字符串內的雙引號:

echo "You're in!  <a href=\"member.php\">Click here</a> to enter the member area";

或者在字符串周圍使用單引號:

echo 'You\'re in!  <a href="member.php">Click here</a> to enter the member area';

更多關於字符串

echo "You're in!  <a href=\"member.php\">Click here</a> to enter the member area"; 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM