The basic outline of a PHP script consists of:
- PHP Opening tag
- Comments
- Statements
- PHP Closing tag
- File name ends .php
<?php //The infamous "Hello, World!" echo("Hello, World! \n") ; ?>
PHP tag, informs interpreter to execute PHP code
<?php ?>
Short codes <? ?> (without the php) can be used but are considered bad form
Comments
Use # or // for a single line
Use /* for
Multiple lines
*/
Statements
In this case the echo() function outputs a quoted string (as its argument) within its parentheses.
NOTE: Each statement must end with a semi-colon ;
Forgetting the semi-colon, is one of the most common problems!!
Whitespace, to make code more readable