php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43802 Differences between asigned references in PHP4 and PHP5
Submitted: 2008-01-09 23:46 UTC Modified: 2008-01-10 00:06 UTC
From: fkieber at free dot fr Assigned:
Status: Not a bug Package: Variables related
PHP Version: 5.2.5 OS: Linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: fkieber at free dot fr
New email:
PHP Version: OS:

 

 [2008-01-09 23:46 UTC] fkieber at free dot fr
Description:
------------
Same as bug #38013 but different behaviour between PHP 4.3.10 and 5.2.5

Reproduce code:
---------------
<?php

function change (&$var) {
  $var += 10;
}

$var = 1;
++$var;
change($var);
echo "var=$var";
$var = 5;
change($var);
echo "var=$var";

$var = 1;
change(++$var);
echo "var=$var";
change($var = 5);
echo "var=$var";

?>


Expected result:
----------------
That one from php 4 :
var=12
var=12

Actual result:
--------------
in PHP 5:
var=12
var=2

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-01-09 23:51 UTC] fkieber at free dot fr
Sorry.
Expected result should be : 
Output in PHP4
var=12
var=15
var=12
var=15

And Actual result is :
Output in PHP5
var=12
var=15
var=2
var=5
 [2008-01-10 00:06 UTC] bjori@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Turn on E_STRICT
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Nov 25 01:01:31 2024 UTC