As Php codes can freely mix with Html codes, special tags are needed to seperate them.
All PHP code must be written between a pair of special start tag and end tag
Tag Style |
Start Tag |
End Tag |
---|---|---|
Standard tags |
<?php |
?> |
Examples of php tag usage are shown below:-
Web pages that contain Php codes must be saved with .php extension.Then only the server will parse the Php codes.
Below is an example of a .php file where PHP and HTML codes were written together.
After saving the above codes as a "helloworld.php" file, place it on a PHP enabled server and view it with your web browser.
You should see "Hello World!" displayed.
PHP function echo was used to to write "Hello World!" to the browser.
More about this PHP function and many others will be explained later.
Every line of Php code must end with a semicolon. It signifies the end of a PHP statement and should never be forgotten.
For example, if we repeated our "Hello World!" code several times, then a semicolon is needed at the end of each statement.
Whitespace is ignored between PHP statements.This means it is OK to have one line of PHP code, then 20 lines of blank space before the next line of PHP code. You can also press tab to indent your code and the PHP interpreter will ignore those spaces as well.
Note
For more detail please see
Php Manual at http://www.php.net