PHP or HTML first or does it matter?

html, php, syntax, tags

Solution

The third one is the correct way (assuming you want the text to echo out in the body).

PHP can jump in and out of HTML as you have shown above.

<html>
<head>
</head>
<body>
<center>
<font size="2"><?php echo "This is text"; ?></font>
</center>
</body>
</html>

Problem

I have a possible stupid question, but I'll ask it anyway. Does it matter what goes first, PHP or HTML code? For example: Does PHP go before HTML, after HTML or does it matter at all? ``` <?php echo "This is text"; ?> <html> <head> </head> <body> <center> <font size="2">This is text</font> </center> </body> </html> ``` Or: ``` <html> <head> </head> <body> <center> <font size="2">This is text</font> </center> </body> </html> <?php echo "This is text"; ?> ``` Or: ``` <html> <head> </head> <body> <?php echo "This is text"; ?> </body> </html> ```

Original source