【发布时间】:2013-01-19 22:05:12
【问题描述】:
如何在下面的回声上应用 css?在为 UTF 编码添加标头之前,我让它工作了,但现在它也回显了 css,所以我的回显结果是:<p align='center'>Good!!!</p>
<?php
header('Content-type: text/plain; charset=utf-8');
$answer = $_POST['1'];
if ($answer == "YES") {
echo 'Good!!!';
}
else {
echo 'Try Again!';
}
?>
更正:
<?php
header('Content-type: text/html; charset=utf-8');
$answer = $_POST['1'];
if ($answer == "YES") {
echo "<p align='center'>Good!!!</p>";
}
else {
echo "<p align='center'>Try Again!</p>";
}
?>
【问题讨论】:
-
你知道
Content-type: text/plain是做什么的吗?即使您不这样做,如果它在此之前有效,则意味着此更改破坏了它。所以谷歌并找出原因。 -
此代码从未回显
<p align... -
为什么将标题设置为 text/plain?没有多大意义,但至少改成
text/html -
CSS?你的意思是HTML?我很困惑...
-
不知道 text/plain 会禁用 html 是的。没有必要像疯了一样投反对票。