A PHP script is executed on the server, and the plain HTML result is sent back to the browser.
A PHP script can be placed anywhere in the document.
A PHP script starts with <?php and ends with ?>:
The default file extension for PHP files is ".php".
A PHP file normally contains HTML tags, and some PHP scripting code.
Below, we have an example of a simple PHP file, with a PHP script that uses a built-in PHP function "echo" to output the text "Hello World!" on a web page:
See this example:
A comment is the portion of a program that exists only for the human reader and stripped out before displaying the programs result.
See this example:
In PHP, all keywords (e.g. if, else, while, echo, etc.), classes, functions, and user-defined functions are NOT case-sensitive.
In the example below, all three echo statements below are legal (and equal):
See this example:
However; all variable names are case-sensitive.
In the example below, only the first statement will display the value of the $book variable (this is because $book, $BOOK, and $BoOk are treated as three different variables):
See this example: