Error analysis when using php5.4 for reference, and error when using php5.4 for reference _ PHP Tutorial

Source: Internet
Author: User
If php5.4 is used for reference, an error is returned. if php5.4 is used for reference, an error is returned. If php5.4 is used for reference, an error is reported. if php5.4 is used for reference, an error is reported. if php5.4 is used for reference, an error is returned. For your reference, refer to the following for details: Error analysis when using php5.4 in the php5.3 series, and error when using php5.4.

This example analyzes the error message returned when php5.4 is referenced. We will share this with you for your reference. The details are as follows:

There is no problem in transferring references from php5.3 series and earlier versions. after php5.4 is upgraded, an error is reported for all references.

Fatal error: Call-time pass-by-reference has been removed in F: \ work \ wamp \ www \ test. php on line 6. Let's take a look at the example below.

Example 1: Recursive Reference transfer. in php 5.3 and later versions, test results

<?phpfunction test($aa,&$bb){  if($aa < $bb){    echo $bb."
"; $bb--; test($aa,&$bb); }}$aa = 3;$bb = 6;test($aa,&$bb);?>

The running result is as follows:

6
5
4

Php 5.4 won't work. I tested it with php 5.4.11. Fatal error: Call-time pass-by-reference has been removed in F: \ work \ wamp \ www \ test. php on line 6 is reported.

For example 2, php5.4.11, the above test, only test transfer reference

<? Phpfunction test ($ aa, & $ bb) {if ($ aa <$ bb) {$ bb --; echo $ bb ."
"; // Test ($ aa, & $ bb) ;}$ aa = 3; $ bb = 6; test ($ aa, $ bb); // php5.4, in php5.3 and earlier versions, the input result is 5 // test ($ aa, & $ bb); // in php5.3, the input result is 5. in php5.4 and later versions, the following error occurs: call-time pass-by-reference...?>

After php5.4, you can define "&". when you call "&", an error is returned. This call is strange.

Example 3: php5.4 and Recursive Reference transfer

<?phpfunction test($aa,&$bb){  if($aa < $bb){    $bb--;    echo $bb."
"; test($aa,$bb); }}$aa = 3;$bb = 6;test($aa,$bb);?>

Php5.2, php5.3, and php5.4 can all be run. the running result is as follows:

5
4
3

It seems that the upgrade from 5.3 to 5.4 is a bit difficult. if you do not know the change, the upgrade will be very depressing.

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.