Home  >  Article  >  Backend Development  >  Analysis of the error when php5.4 is quoted, error when php5.4 is quoted_PHP Tutorial

Analysis of the error when php5.4 is quoted, error when php5.4 is quoted_PHP Tutorial

WBOY
WBOYOriginal
2016-07-12 09:00:111038browse

Analysis of the error when passing a reference in php5.4, and an error when passing a reference in php5.4

This article analyzes the error problem when passing a reference in php5.4. Share it with everyone for your reference, the details are as follows:

In php5.3 series and previous versions, there is no problem in passing references. After upgrading to php5.4, all errors are reported when passing references

Fatal error: Call-time pass-by-reference has been removed in F:workwampwwwtesttest.php on line 6. Take a look at the example below.

Example 1, recursive reference transfer, test results in PHP 5.3 and above

<&#63;php
function test($aa,&$bb){
  if($aa < $bb){
    echo $bb."<br>";
    $bb--;
    test($aa,&$bb);
  }
}
$aa = 3;
$bb = 6;
test($aa,&$bb);
&#63;>

The running results are as follows

6
5
4

It won’t work after PHP 5.4. I tested it with PHP 5.4.11. ReportedFatal error: Call-time pass-by-reference has been removed in F:workwampwwwtesttest.php on line 6.

Example 2, tested on php5.4.11, only passing references

<&#63;php
function test($aa,&$bb){
  if($aa < $bb){
    $bb--;
    echo $bb."<br>";
    //test($aa,&$bb);
  }
}
$aa = 3;
$bb = 6;
test($aa,$bb); //php5.4,php5.3及以前版本,输入结果是5
//test($aa,&$bb); //php5.3输入结果是5,php5.4及以后,报错Fatal error: Call-time pass-by-reference 。。。。
&#63;>

After php5.4, you can have & when defining. If you add & when calling, an error will be reported. It feels weird to call it this way.

Example 3, php5.4 and recursive reference

<&#63;php
function test($aa,&$bb){
  if($aa < $bb){
    $bb--;
    echo $bb."<br>";
    test($aa,$bb);
  }
}
$aa = 3;
$bb = 6;
test($aa,$bb);
&#63;>

php5.2, php5.3, and php5.4 can all be run. The results are:

5
4
3

I feel that upgrading from 5.3 to 5.4 is a bit cheating. If you don’t know the changes, upgrading will be very depressing.

Readers who are interested in more content related to PHP errors and exceptions can check out this site's special topic: "Summary of PHP Error and Exception Handling Methods"

I hope this article will be helpful to everyone in PHP programming.

Articles you may be interested in:

  • How to upgrade php5.3 version to php5.4 or php5.5
  • htmlspecialchars output under GBK encoding of php5.4 or above version Summary of solutions to the empty problem
  • Full records of compiling PHP5.4 and xdebug under Windows
  • Solutions for json versions below php5.4 that do not support unescaped Chinese content
  • Note: php5.4 has deleted the session_unregister function
  • Install apache2.2.22 to configure php5.4 (specific steps)
  • Summary of changes in json_encode Chinese transcoding in PHP5.4
  • Some errors that occurred after php was upgraded to 5.3, such as ereg(); ereg_replace(); function error
  • Exploring the reason why the PHP script does not report an error
  • Solution to the PHP empty function error
  • A simple solution to the error when php starts up
  • How to solve the error when php starts up

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1094747.htmlTechArticleAnalysis of the error when php5.4 is quoted, and an error when php5.4 is quoted. This article provides an example analysis of php5.4. An error occurred when citing. Share it with everyone for your reference, the details are as follows: php5.3 series version...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn