亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

我將如何設計回聲?

我將如何設計回聲?

PHP
收到一只叮咚 2022-05-27 16:54:03
我想知道如何在 php 中設置 echo 樣式?我試圖設置嵌套在其中一個回聲中的段落標簽的樣式,如果有人能告訴我如何做到這一點,我將不勝感激。謝謝PHPif(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;}
查看完整描述

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>


查看完整回答
反對 回復 2022-05-27
?
回首憶惘然

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>";



查看完整回答
反對 回復 2022-05-27
  • 2 回答
  • 0 關注
  • 138 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號