我想知道如何在php中设置回声的样式?我试图设置嵌套在回声之一中的段落标签的样式,如果有人可以告诉我该怎么做,我将不胜感激。谢谢
PHP
if(isset($_SESSION['sess_user_id']) && $_SESSION['sess_user_name'] != "") {
echo '<h1>Welcome '.$_SESSION['sess_user_name'].'</h1>';
echo "<p id="profileText"This is your personal profile page, from here you can edit events</p>";
echo '<h4><a href="logout.php">Logout</a></h4>';
}
else {
header('location:index.php');
CSS
#profileText {
top: 40%;
position: absolute;
color: blue;
}
答案 0 :(得分:1)
更好的是,不要从您的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>
这样
<p id="profileText"This is your personal profile page, from here you can edit events</p>
答案 1 :(得分:0)
您遇到语法错误。
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>";