Differences between PHP array indexes without quotation marks

Source: Internet
Author: User
Today, a student asked me a question: why can I run the output index array key without quotation marks? What is the difference between adding and adding quotation marks? Let's look at an example? Php $ url $ _ SERVER [REQUEST_URI]; echo1 ----. $ url.br; $ urlparse_url ($ url); echo2 ----. $ url [path]. br; echo3 --

Today, a student asked me a question: why can I run the output index array key without quotation marks? What is the difference between adding and adding quotation marks? Let's look at an example? Php $ url = $ _ SERVER ['request _ URI ']; echo 1 ----. $ url.br/; $ url = parse_url ($ url); echo 2 ----. $ url [path]. br/; echo 3 --

Today, a student asked me a question: why can I run the output index array without quotation marks? What is the difference between adding and adding quotation marks?

Let's take an example.

 "; $ Url = parse_url ($ url); echo" 2 ---- ". $ url [path]."
"; Echo" 3 ---- ". $ url [" path "]."
";

Their output results are as follows: 2 and 3 can both output the same value, but for 2, if there is no configuration-related information in the php. ini configuration file, there will be warning information and no configuration will be available.

Related configuration file: error_reporting = ~ E_NOTICE and output without quotation marks will affect performance! We recommend that you use quotation marks ..

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.