Reputation: 159
I'm trying to display the following and I have a css code for it but it doesn't work. Any help would be appreciated.
HTML/PHP
$var = "Hello World";
echo '<p>' . 'the value of the variable is : ' . $var . '</p>';
CSS
p
{
text-align: center;
color: red;
}
Thanks for your help
Upvotes: 2
Views: 11977
Reputation: 508
Use as below
<?php
$var = "Hello World";
echo "<p>The value of the variable is : " . $var . "</p>";
?>
Or like below in your HTML code where you want the php variable
<p>The value of the variable is : <?php echo $var;?></p>
Upvotes: 0
Reputation: 9117
Try this.. run in your php enviroment
<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>
Upvotes: 1
Reputation: 362
Its working for me in 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>
Upvotes: 0