When PHP compiler parses a PHP file, It looks opening and closing tag of PHP which is '<?php' and '?>' These opening and closing tag tells the compiler to interpret the code between '<?php' and '?>'
Does PHP also support short open tag <?.
This feature is available if enabled this short_open_tag in the php.ini configuration file.
like C PHP requires a semicolon at the end of every statement.
Start Tag : <?php
End Tag : ?>
A Simple Program
<?php some code here... ?>
Before making a PHP program you need a code editor such as Notepad, Notepad++ and etc. and a web browser such as Google Chrome, Mozilla Firefox, Safari and Internet Explorer, etc. to view the output of the program.
Write some PHP code between <?php and ?>.
save this file as "index.php", .php extension is must for execute this program in PHP parser.
Save this file anywhere inside in the root directory of the server.
Open the web browser and type "127.0.0.1:80/index.php" in the URL address bar and hit enter.
<!DOCTYPE html> <html> <head> <title>A Simple Program</title> </head> <body> <?php echo "<h1>This is my first PHP program</h1>"; ?>
Comments in PHP
PHP supports single line and multiline comments
<?php // This is the single-line comment # This is the single-line comment /* This is the multiline comment line 1 line 2 : : line n */ ?>