3. PHP Tutorial _3. PHP syntax

Source: Internet
Author: User

Basic PHP syntax

The PHP script can be placed anywhere in the document.

The PHP script starts with <?php and ends with?>:

1 <? PHP 2     // PHP Code 3 ?>

The default file name extension for PHP files is ". php".

PHP files usually contain HTML tags and some PHP script code.

Below, we provide a simple example of a PHP file that can output the text "Hello world!" to the browser:

1 <! DOCTYPE html> 2   3  <body> 4  5   6  7 <?php 8  echo "Hello world!"; 9  ?>11
      </body>  

Each line of code in PHP must end with a semicolon. A semicolon is a delimiter used to differentiate the instruction set.

With PHP, there are two basic instructions for outputting text in the browser:echo and print.

Comments in PHP

1 <! DOCTYPE html> 2   3  <body> 4  5 <?php 6  //This is PHP single line comment 7  8/* 9 This is PHP multi-line  note */13  ?>  </body>  

3. PHP Tutorial _3. PHP syntax

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.