PHP array access to some questions about guessing

Source: Internet
Author: User
Tags php source code
PHP array access to some problem guessing

First: It is said that the PHP array is a copy of the Perl array, but its use has been simplified.

So, to access the members of an array is naturally:

$ array name [key name]

Or

$ array Name {key Name}

In Perl, the [] index refers to an array, and {} is dedicated to a hash array.

However, there is no description of the {} index in the official PHP documentation. is only present in the user commentary. Naturally, I think these users must have read the PHP source code. Maybe it was a casual test.

But anyway, if you don't look at the source code, there is no way to know the real difference between the two.

?

Another point is that you can access a single character in a string in an array way. However, if the variable is empty. Use an array to write a string to it, then the group.

?

For strings, I personally prefer to use the {} index access. The fundamental purpose of this is to differentiate it from the array. Indicates that this variable is a string.

?

For the difference between [] and {}, you need to look at the source code for a second time. Just make a record in some.

  • 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.