我试图显示以下内容并且我有一个css代码,但它不起作用。任何帮助将不胜感激。
HTML / PHP
$var = "Hello World";
echo '<p>' . 'the value of the variable is : ' . $var . '</p>';
CSS
p
{
text-align: center;
color: red;
}
感谢您的帮助
答案 0 :(得分:0)
使用如下
<?php
$var = "Hello World";
echo "<p>The value of the variable is : " . $var . "</p>";
?>
或者在你想要php变量的HTML代码中如下所示
<p>The value of the variable is : <?php echo $var;?></p>
答案 1 :(得分:0)
它在localhost中为我工作。
<?php
$var = "Hello World";
echo '<p>' . 'the value of the variable is : ' . $var . '</p>';
?>
<style type="text/css">
p
{
text-align: center;
color: red;
}
</style>
答案 2 :(得分:0)
试试这个..在你的php环境中运行
<html>
<head>
<style type="text/css">
p
{
text-align: center;
color: red;
}
</style>
</head>
<body>
<?php
$var = "Hello World";
echo "<p>The value of the variable is : " . $var . "</p>";
?>
</body>
</html>
答案 3 :(得分:0)
$var = "Hello World";
echo '<p style="color:blue;margin-left:30px;">the value of the variable is : ' . $var . '</p>';