PHP: non-general syntax record

Source: Internet
Author: User
PHP: most of the php syntax records are similar to asp and other interpretation syntaxes, but there are still some minor differences. in the process of familiarizing yourself with php syntax, the differences are recorded here as notes. 1. in PHP, the concatenation operator has only one string operator. The concatenation operator (.) is used to connect two string values. To connect two variables together, use this PHP: special syntax record.

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 (.):

 

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['Joe'] = "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.


--------------------------------------- Reprinted please indicate the source: CNZQS | JesseZhang's personal blog-"php: special syntax record" this article link address: http://www.cnzqs.com /? P = 72
Related Article

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.