PHP Syntax

A PHP script starts with the <?php and ends with the ?> tag which tell PHP to start and stop interpreting the code between them and Every PHP statement end with a semicolon (;)

Below the example of long tag:

<!DOCTYPE html>
<html lang="en">
<head></head>
<body>
     <?php echo 'Hello, World'; ?>
</body>
</html>

Output: Hello, World

PHP also allows for short open tag <? (which is discouraged since it is only available if enabled using the short_open_tag php.ini configuration file directive, or if PHP was configured with the --enable-short-tags option).

<? and <?= are called short open tags, and are not always enabled short_open_tag directive) with PHP 5.3 or below (but since PHP 5.4.0, <?= is always available).

Below the example of short tag:

<!DOCTYPE html>
<html lang="en">
<head></head>
<body>
     <?= 'Hello, World'; ?>
</body>
</html>

Output: Hello, World