Analysis of mistakes in single double quotation marks in PHP and hidden risks in double quotation marks, php double quotation marks

Source: Internet
Author: User

Analysis of mistakes in single double quotation marks in PHP and hidden risks in double quotation marks, php double quotation marks

Many Programmers think that single quotes and double quotes are the same in PHP. In fact, this depends on how they are used. They are indeed the same in some aspects, but there are also great differences in some aspects, let's talk about the differences for you today.

1. Generally, the two are generic. However, if a variable is written in double quotation marks, the parsing operation is executed, but the single quotation marks are not parsed? Let's take an example.

Now I see it!

2. The execution efficiency is different. The execution speed of single quotes is faster than that of double quotes. If it is a large program, you should pay attention to optimization. After all, PHP is an interpreted language. Therefore, if you use single quotes (fast speed) when there are only pure strings inside, and other items (such as variables) inside, double quotes will be more flexible.

PHP double quotes

Many PHP syntax features allow attackers to take advantage of them. For example, PHP detects variables in double quotes.

Run the following code:

Function test () {echo "abc";} echo "$ {@ test ()}"; // or echo $ {@ phpinfo ()};

The principle is as follows:

$ A = 'B'; $ B = 'a'; echo $ a; //

The above uses PHP variable variables. The variable content characteristics in double quotation marks {} can be parsed in double quotation marks, which makes little trouble. Do you understand this? Programmers should pay more attention to these misunderstandings and hidden dangers.

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.