<?php is used to mark "start of script".
<?php $foo = "bar"; echo $foo; ?>
?> is used to mark "end of script".
Whatever is inside <?php ?> will be processed as PHP script.
<?php $title = "TEST"; $txt = "<h1>PAGE</h1>"; ?> <!DOCTYPE html> <html> <head> <title><?php echo $title; ?></title> </head> <body><?php echo $txt; ?></body> </html>
Whatever is outside will output as it is.
Use <?=$VAR?> to quickly output a PHP variable.
<?php $foo = "bar"; ?> <p><?=$foo?></p>