PHP Basic Syntax

Source: Internet
Author: User

1. What is PHP?

    • PHP is a cross-platform running on the server side (PHP is used to handle server-side data) (can be run on multiple platforms, such as Linux,windows,unix ...) scripting language (and a line of computer instructions is used to communicate with the server, and the language of communication is PHP).

Code identification for 2.PHP

    • <?php?>, you can embed the PHP language in any location in an HTML file that will be named. PHP at a later time.

Print a string (output statement) in 3.PHP

Answer:Echo

4. Instruction delimiter "semicolon"

    • Directives: statements in a program that perform certain functions, called Directives .

PHP needs to end with a semicolon after each instruction.

5.PHP Program Notes

    • Multiline Comment:/* */

Single-line Comment://or #

Note: Note that the comment must be written on or to the right of the commented code, and not written under the code.

Calculation Expressions in 6.PHP

    • PHP differs from HTML and CSS in that it can be computed

Example: <?php echo 12*3;?>

String in 7.PHP

A: single quotes: PHP does not parse the variables inside the single quotes, and the variables are output as-is. Using single quotes is more efficient when defining simple strings.

Double quotation marks: the variables inside the double-quoted string are substituted by the value of the variable.

String operators (connectors) in 8.PHP

    • " . "

Example: <?php echo "Hello". ", Hi";?>

Variables in the 9.PHP

    • Variables: variables are shipped to store values.
    • Declaration: Use the " $ " sign followed by the variable name

10. Naming of variables

    • The composition of a variable: a letter, an underscore, a letter, a number, an underscore, and a Chinese character.
    • Note: variable names are strictly size-sensitive.

11. Variable variable

    • Made up of two $$

12. Assigning a reference to a variable

    • Use the "&" symbol to add the & symbol to the variable that will be assigned

  

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.