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>
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>
Personally I put the PHP as much as possible at the top of the page or even better outside the html page completely by using the html pages as purely views in the MVC pattern.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With