Basic PHP Syntax (Syntax)
If you want to write a PHP code on a webpage, you should end it.
On a server that supports shorthand, you can use it to start and end the PHP script block.
In order to ensure that your PHP files work in different environments, it is strongly recommended that you use the first method. To end.
An example of a simple PHP file
You can write the following code with Notepad, which is the simplest PHP file.
One of the most common functions of PHP is echo, which is the output text.
Save PHP Files
PHP files use. php as the file name extension.
For example, you can save the above example as blabla.php.
Run the PHP sample file
Enter the URL path of the above PHP sample file in the browser and you will see that the result is:
blabla.cn
Please use the browser to view the sample Web page source code, you will find that you do not see the above example file written in the PHP code, you see only the PHP script after the execution of the HTML, as follows:
blabla.cn
The user can not see the source code of the PHP file, only see the output of the PHP file after execution.
The role of semicolons (semicolon) in the PHP language: instruction delimiter (instruction separation)
In the PHP language, a semicolon (semicolon) indicates the end of a PHP instruction, remember to add a semicolon after each PHP instruction, but in a PHP script block, the last instruction can be used without a semicolon, because?> automatically implies a semicolon, and of course you do not have an error with the semicolon.
For example, we use a semicolon to separate two echo statements, as follows:
Space
Spaces are ignored between two PHP instructions.
The output HTML results are the same for the following three types of notation.