This article mainly introduces the problem of errors reported by reference in php5.4, and analyzes the problem and solution of errors reported by reference in php5.4 based on the instance form, which has some reference value, if you need it, you can refer to the example in this article to analyze the error message returned when you reference php5.4. 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.