PHP Syntax (Syntax)

Source: Internet
Author: User
Tags php language
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.

 
  
 
  
 
  
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.