PHP Fatal error:cannot pass parameter 2 by reference

Source: Internet
Author: User
Tags php error

PHP Fatal error:cannot pass parameter 2 by reference in

This error means that the 2nd argument cannot be passed as a reference

My understanding is that the 2nd parameter of the method needs to pass a variable

Local PHP is 5.4.35

The situation I have appeared is as follows:

1<?PHP2 3 functionTest$param 1,&$param 2){4   $param 2++;5 }6 7 //this way the call will show Fatal error:only variables can be passed by reference in/var/www/html/test.php on line 98 //Because the second parameter is not a variable9 //test (a);Ten  One //In the case of no modification of the method A //The correct method is to store the value of the second parameter in a variable, such as - $param 3= 1; -Test (1,$param 3); the //now the value of $PARAM3 is 2.

The essay references:

    1. Reference delivery

    2. "PHP error" cannot pass parameter 2 by reference

    3. Fatal Error:cannot pass parameter 2 by reference

PHP Fatal error:cannot pass parameter 2 by reference

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.