2 回答

TA貢獻1798條經驗 獲得超3個贊
更好的是,不要從您的 php 邏輯中進行演示。考慮一下:
<?php
if(!isset($_SESSION['sess_user_id']) || $_SESSION['sess_user_name'] == "") {
header('location:index.php');
}
// do any other php stuff...
?>
<h1>Welcome <?= $_SESSION['sess_user_name'] ?></h1>
<p id="profileText">This is your personal profile page, from here you can edit events</p>
<h4><a href="logout.php">Logout</a></h4>
這邊走,
你的邏輯和表達是明確分開的
如果您想更改演示文稿,您不必亂用您的 php 代碼
您不必擔心單引號/雙引號/轉義引號/等等,等等,等等。
您不必擔心標題之前的輸出
你之后的程序員會驚訝于你的代碼是多么干凈:)
它可以讓您輕松查看拼寫錯誤:
<p id="profileText"This is your personal profile page, from here you can edit events</p>

TA貢獻1847條經驗 獲得超11個贊
你有語法錯誤。
echo "<p id="profileText"This is your personal profile page, from here you can edit events</p>";
在您的回聲中使用單引號。
echo "<p id='profileText'>This is your personal profile page, from here you can edit events</p>";
如果您在回顯中使用雙引號,則不能在字符串中使用另一個雙引號。你可以這樣做:
echo "<p id=\"profileText\"> This is your personal profile page, from here you can edit events</p>";
或者你可以在你的字符串上使用單引號
echo "<p id='profileText'>This is your personal profile page, from here you can edit events</p>";
- 2 回答
- 0 關注
- 138 瀏覽
添加回答
舉報