How to write html code inside <?php ?> block?

html, php

Solution

You can do like

HTML in PHP :

<?php
     echo "<table>";
     echo "<tr>";
     echo "<td>Name</td>";
     echo "<td>".$name."</td>";
     echo "</tr>";
     echo "</table>";
?>

Or You can write like.

PHP in HTML :

<?php /*Do some PHP calculation or something*/ ?>
     <table>
         <tr>
             <td>Name</td>
             <td><?php echo $name;?></td>
         </tr>
     </table>

`<?php /*Do some PHP calculation or something*/ ?>` Means: You can open a PHP tag with `<?php`, now add your PHP code, then close the tag with `?>` and then write your html code. When needed to add more PHP, just open another PHP tag with `<?php`.

Problem

I want to create a table with `<?php ?>` script. How can I insert html code into `<?php ?>` to achieve my goal? ``` <?php html code to create table ?> ```

Original source