是否可以在PHP中以这种方式使用CSS? [关闭]

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?

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.

Its possible but you made a mistake

echo "style=" font-size:32;

Php will search for the method font-size:32. It wilp not find it and this causes an error. Use "" to define the string and use ' ' for inline css:

echo"style='font-size:32px'";

Try this it may helps. I just modified your code little bit in the 1st echo. It just the issue of using quote operator. Thanks

    <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>