如何设置带有多个变量的 echo 函数的样式
How to style a echo function with multiple variables
我希望我的代码在同一个 echo 函数上显示两个变量,但是,我希望它们以不同的方式设置它们的样式。使 'id' 更小,颜色不同。我不知道如何将这两个变量分开,所以我可以在两者之间添加一些代码。
我尝试使用第二个 echo 函数,但是 'id' 显示在底部,与 'quote' 函数分开。
echo "<p class='dash'>---------</p>","<p class='center' style='color:white' align='center'>" .$row['quote'] .$row['id'];
输出将像这样显示(输出的粗体文本):
--------
"This is the quote variable"1
但是我需要的是这样显示的:
------
"This is the quote variable"
1
所以基本上需要的是某种方法来为第二个添加样式。 (我已经设计了第一个)
另一种消除点连接运算符的方法:
<?php
$row["quote"] = "This is the quote";
$row["id"] = 1;
$p = [];
$p[0] = "<p class='dash'>---------</p>\n";
$p[1] = "<p class='center' style='color:white' align='center'>$row[quote]<br>\n$row[id]</p>\n";
echo $p[0],$p[1];
示例 HTML 实施:
.dash {
color: blue;
font-weight: 300;
}
.center {
text-algin: center font-weight:900;
}
body {
background:navy
}
<p class='dash'>---------</p>
<p class='center' style='color:white' align='center'>This is the quote<br> 1
</p>
我希望我的代码在同一个 echo 函数上显示两个变量,但是,我希望它们以不同的方式设置它们的样式。使 'id' 更小,颜色不同。我不知道如何将这两个变量分开,所以我可以在两者之间添加一些代码。
我尝试使用第二个 echo 函数,但是 'id' 显示在底部,与 'quote' 函数分开。
echo "<p class='dash'>---------</p>","<p class='center' style='color:white' align='center'>" .$row['quote'] .$row['id'];
输出将像这样显示(输出的粗体文本):
--------
"This is the quote variable"1
但是我需要的是这样显示的:
------
"This is the quote variable"
1
所以基本上需要的是某种方法来为第二个添加样式。 (我已经设计了第一个)
另一种消除点连接运算符的方法:
<?php
$row["quote"] = "This is the quote";
$row["id"] = 1;
$p = [];
$p[0] = "<p class='dash'>---------</p>\n";
$p[1] = "<p class='center' style='color:white' align='center'>$row[quote]<br>\n$row[id]</p>\n";
echo $p[0],$p[1];
示例 HTML 实施:
.dash {
color: blue;
font-weight: 300;
}
.center {
text-algin: center font-weight:900;
}
body {
background:navy
}
<p class='dash'>---------</p>
<p class='center' style='color:white' align='center'>This is the quote<br> 1
</p>