PHP Basic Syntax

Source: Internet
Author: User

PHP code begins with <?php, ends with?>, and can be placed anywhere in the document

Note PHP also allows the use of short mark < And, but not encouraged to use. Short marks can be used only by activating the Short_open_tag configuration directive in php.ini or by using the configuration option--enable-short-tags when compiling PHP

Each PHP statement is separated by a semicolon (;) end, and the close tag of the PHP block automatically indicates the semicolon. The easiest mistake to make in PHP programming is to forget to add a semicolon, which causes PHP to think of a multiline statement as a statement, which makes PHP unintelligible, and the system gives a "parse error" message

PHP supports three types of annotations, including two single-line comments and one multiline comment

[note] comments cannot be nested

<?php//This is a single-line comment # This is also a single-line comment/* This is a multiline comment block which spans multiple lines */?>

In PHP, there are two basic output methods: Echo and Print

Print can output only one string, and always returns 1

Echo is capable of outputting more than one string, and echo is slightly faster than print because it does not return any value

[Note that both]echo and print are language structures, with either echo or Echo (), as well as print or print (), with or without parentheses, and at least one space between the echo or print keyword and the string

Calculation expressions can be written in PHP

<?php    //36    echo 12*3;? >
In PHP, all user-defined functions, classes, and keywords are case insensitive, but all variables are case-insensitive
[note]. The number represents a string connection, in other programming languages, usually with the + sign
In general, whitespace characters (including spaces, tab tabs, line breaks) do not matter in PHP and are ignored by the PHP engine. You can expand a statement into any row, or tighten the statement together,
It can enhance the clarity and readability of program code by using space and blank line rationally.

PHP Basic 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.