我可以在php中使用这种语法吗? [重复]

This question already has an answer here:

<?php
   if(something==something){
      for($i=0;$i<sizeof($array);$i++){
 ?>
<table>
   <tr>
      <th><?php echo date("m d y");?></th>
   </tr>
</table>
    <?php
   }
  }
?>

If I would use sintax like thiks would the code work? I couldn't find any discussion on this, and I am new to php so every advice would be helpful and appreciated. Thanks!

</div>

No, but you can do this:

<?php if(something==something){ 
     for($i=0;$i<sizeof(array);$i++){
         echo "<table><tr><th>";
         echo date("m d y");
         echo "</th> </tr> </table>";
      }
 } ?>

Yes, you can.

1) Actually you can use php within html.

Eg : - <h1><?php echo "hello world"; ?> .

2) You can't use html within php. But exception if you use echo with html

Eg :- <?php echo "<h1>Hello world</h1>"; ?>

You can use HTML inside you PHP code.

<?php
    if(something==something){
    for($i=0;$i<sizeof($array);$i++){
        echo '<table>
              <tr>
              <th>'.date("Y-m-d").'</th>
              </tr>
          </table>';
    }
    }
?>