PHP Reference Transfer specification problem

Source: Internet
Author: User

In my previous article: SHOPNC Mall Source Reading notes-The opening overview, encountered a PHP reference value caused by the error, the situation is as follows:

When I check the English version of the official PHP document http://php.net/manual/zh/language.references.pass.php

See the following description:

Note that there is no reference symbol in the function call-only in the function definition. The function definition alone is enough to make the argument pass through the reference correctly. In the most recent version of PHP, if you use & in foo (& $a) , you will get a warning that "call-time pass-by-reference" is obsolete.

Then switch to the English version of the document to get the following description:

Note: There is no reference sign on a function call-only on function definitions. Function definitions alone is enough to correctly pass the argument by reference. As of PHP 5.3.0, you'll get a warning saying that "call-time pass-by-reference" was deprecated when you use & in Foo (& $a);. And as of PHP 5.4.0, Call-time pass-by-reference is removed, so using it would raise a fatal error.

The pit Si person does not have the die to have the wood to have!

A gently, gentle to tell you, it's OK, not very painful, all of a sudden, let you useful @ shielding the impulse of warning

It's actually going to hurt you so much that you can't go on at all.

So there's nothing to this question why, very clear

The function definition alone is sufficient for the parameter to be passed correctly by reference, as

function test (&var) {

}

You do not have to pass the reference when you call test, such as test (&var); Otherwise the fatal error will be reported, the same as not write a semicolon, there is no why!

Also gain a valuable experience: later in the official documents, do not read the Chinese version.

If the English is not good, you can collect the relevant blog post, see others summed up the knowledge is better than looking at the official Chinese documents.

PHP Reference Transfer specification problem

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.