Doglas Doglas - 5 months ago 9
HTML Question

Is it posible to use CSS in this way in PHP?

I'm trying to use CSS within PHP code but it seems that I can't use CSS in the way that I'm trying. why?

<?php

$username = "Daved";
$password = "hello!";

?>

<html>
<head>
</head>

<body>

<?php

echo "<div style="font-size: 32px; background-color:#f00; color:#fff; width:200px;">And Operation</div>";
if($username == "Daved" && $password == "hello!"){

echo "<p>The Password and UserName are correct!</p>";
}

else {
echo "<p>You are not a member!</p>";
}

?>
</body>

</html>


Ok, It's a true way to use CSS like this, or I must to try using style in another way?

Answer

Actual Problem is your echo statement. It should be noted that the echo prints whatever is in between " " or ''. Hence your statement echo "<div style="font-size: 32px; background-color:#f00; color:#fff; width:200px;">And Operation</div>"; is closing at style=". Hence your code is not working change it to echo "<div style='font-size: 32px; background-color:#f00; color:#fff; width:200px;'>And Operation</div>";. It will surely work.

Comments