PHP Basic Syntax

Source: Internet
Author: User

1. PHP grammar rules?

1) Since we have configured the php file extension. php in the master configuration file for Apache, all PHP files have the extension. php;

2) PHP files must be accessed through the domain name, PHP files can not contain Chinese;

3) PHP must have '; ' after each statement;

4) Variables in PHP must be case-sensitive, the remaining functions, method names, class names are not case-sensitive, but the recommendations are differentiated;

2. PHP tags?

1) Standard format: <?php.....code?> also called XML format;

2) script format: <script language= "PHP" > Echo data (' y-m-d h:i:s '); </script>

3) Short format: <? Code ...? > Default server is not configured in this format, you need to manually configure the php.ini file to open the short format

3. Variables and operations?

Programming language is the operation of memory (read and write to memory)

4. What is the name of the variable?

1) Syntax: $ variable name = value;

2) Description: The variables in PHP must start with the ' $ ' sign;

Variable names can only contain letters, numbers, underscores, and can only start with letters and underscores;

3) If it is a pure PHP code file,?> this terminator tag suggested omitted, if there are other languages in this file, you must add the end tag, not omitted, otherwise error;

4) Define the variable: $v 1 = 1;   Definition $v 1 = 10; Change the value of a variable

5) Delete the variable (destroy the variable from memory): unset ($v 1); If the variable is not defined, the output of this variable with ECHO will also report an error, and the variable undefined is undefined;

5. Variable variable?

1) For example: Define a variable $v = age;    $age = 20;   The output echo $v;  Age if output echo $ $v; 20

2) function of variable variables: 1. Access another variable by one variable; (the example above is to access the $age variable via $v).

      

2. Create another variable with one variable;

        

3) Code output value is 10, principle such as;

    

  

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.