PHP: Special syntax record

Source: Internet
Author: User

 

Most php syntaxes are similar to asp and other interpretation syntaxes, but there are still some minor differences. In the process of familiarizing yourself with php syntaxes, the relevant differences are recorded here, take notes.

1. concatenation operator

In PHP, there is only one string operator.

The concatenation operator (.) is used to connect two string values.

To connect two variables together, use the dot operator (.):

<? Php $ txt1 = "Hello World"; $ txt2 = "1234"; echo $ txt1. "". $ txt2;?>

The Code is as above. In other languages, it is usually "+". Here "." is equivalent to "+"

2. Associate an array

Join array. Each ID key is associated with a value.

It is not the best practice to use a numeric array to store data related to specific named values.

By associating arrays, we can use values as keys and assign values to them.

Associated numbers are similar to hashtable.

There are two ways to create an instance:

$ Ages = array ("Peter" => 32, "Quagmire" => 30, "Joe" => 34 );

$ Ages ['Peter '] = "32"; $ ages ['quagmire'] = "30"; $ ages ['job'] = "34 ";

Through the above example, we can also understand the "=>" value assignment operator.

3. Variable

You can dynamically change the name of a variable.

$ Test_1 = 5; $ test_2 = test_1; $ test_2 = 10; echo $ test_1;

4. Reference Operators

Reference OPERATOR: "&" references an alias instead of a pointer. Point to the same address in the memory.

5. Error suppression OPERATOR :@

6. Execution operators:

The execution operator "." is used to execute commands. For example:

$ Export test = 'dir c :';

Echo $ shorttest;

7. type operators:

Type Operator: instanceof. Check whether an object is an instance of a specific class.

 

-----------------------------------------

For more information, see Source: CNZQS | personal blog of JesseZhang-php: Special syntax record

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.