当前位置: 动力学知识库 > 问答 > 编程问答 >

What is the correct way to apply css on php echo?

问题描述:

How can I apply css on my echoes below? I got it to work before I added the header for UTF encoding but now it echoes the css too so my echo result was: <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!';

}

?>

CORRECTED:

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

}

?>

网友答案:

You're sending the header:

Content-type: text/plain;

which tells the browser that the incoming data is plain text, and not html so any markup in the returned data is ignored.

分享给朋友:
您可能感兴趣的文章:
随机阅读: