PHP versions earlier than 5.3 cannot directly retrieve the array returned by the function using subscript

Source: Internet
Author: User

A piece of code written locally (PhP 5.5.2 environment) has the following operations:

... Echo multilang ('menu ') [0];

Mutilang is used to determine the returned results in multiple languages. The returned value is a one-dimensional array.

No problems were found locally, but the program upload server encountered an error.

Syntax error, unexpected '[', expecting ';'

It means there is an unexpected '[' instead ';'

In this way:

$ TMP = multilang ('menu '); echo $ TMP [0];

But the output is normal.

No errors were found in all aspects of the check.

Later, I went online to Google and found that the version was not supported.

The current server version is 5.2.17. So I switched to php5.4.18on the server and found that no error was reported and the operation was normal.

It turns out that this expression is only supported in Versions later than PhP 5.3. The specific reasons have not been discussed. This is a question worth figuring out.

This article is also posted on my independent blog. mc-zone.me, click
Access this 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.