php5.4 Citation times error problem analysis _php skills

Source: Internet
Author: User
Tags exception handling php error

This paper analyses the problem of php5.4 citation times error. Share to everyone for your reference, specific as follows:

php5.3 Series version and previous version, the reference is not a problem, upgrade to php5.4 after, the reference to the place, the full error

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

Example 1, recursive reference, in PHP 5.3 and the version, test results

<?php
function Test ($aa,& $bb) {
  if ($aa < $BB) {
    echo $bb. " <br> ";
    $BB--;
    Test ($aa,& $bb);
  }
$AA = 3;
$BB = 6;
Test ($aa,& $bb);
? >

The results of the operation are as follows

6
5
4

PHP 5.4 After the 5.4.11, I was tested with PHP. Newspaper Fatal Error:call-time pass-by-reference has beenremoved in F:\work\wamp\www\test\test.php to line 6.

Example 2,php5.4.11 above test, only test pass reference

<?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 and previous versions, the input result is 5
//test ($aa,& $bb);//php5.3 input result is 5,php5.4 and later, error fatal Error:call-time Pass-by-reference .....
?>

After php5.4, you can have an ampersand when you define it, and when you add &, you will get an error. It's weird to call this.

Example 3,php5.4 and recursive reference

<?php
function Test ($aa,& $bb) {
  if ($aa < $BB) {
    $BB-;
    echo $BB. " <br> ";
    Test ($AA, $BB);
  }
$AA = 3;
$BB = 6;
Test ($AA, $BB);
? >

php5.2,php5.3,php5.4 can run, run results:

5
4
3

Feel this 5.3 liters to 5.4 a bit pit dad, if you do not know the change, the upgrade is very depressed.

More about PHP error and exception related content readers can view the site topics: "PHP error and Exception handling method Summary"

I hope this article will help you with the PHP program design.

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.