#42268 [Opn->Csd]: assignment in reference parameter doesn't resolve properly
| From: | donauinsel at hotmail dot com | Date: | Mon, 13 Aug 2007 09:46:50 +0000 |
| Subject: | #42268 [Opn->Csd]: assignment in reference parameter doesn't resolve properly | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-116010@lists.php.net to get a copy of this message | ||
ID: 42268
User updated by: donauinsel at hotmail dot com
Reported By: donauinsel at hotmail dot com
-Status: Open
+Status: Closed
Bug Type: *General Issues
Operating System: W32
PHP Version: 5.2.4RC1
New Comment:
Sorry , missed message from Cristian Rodriguez. Thanks for explaining.
Previous Comments:
------------------------------------------------------------------------
[2007-08-13 09:22:10] donauinsel at hotmail dot com
Can you please explain why it works until latest PHP release but not in
5.2.3 ?!
------------------------------------------------------------------------
[2007-08-11 06:33:09] donauinsel at hotmail dot com
This works by example also when using references. So there is going
something wrong with php.
$prevmonth = ($month - 1);
$prevyear = ($year + 0);
$nextmonth = ($month + 1);
$nextyear = ($year + 0);
fixdate($prevmonth, $prevyear);
fixdate($nextmonth, $nextyear);
------------------------------------------------------------------------
[2007-08-11 04:21:34] donauinsel at hotmail dot com
Sorry i don't understand what you mean. I use the pass-by-reference
function with global variable.
------------------------------------------------------------------------
[2007-08-10 21:43:28] johannes@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
.
------------------------------------------------------------------------
[2007-08-10 20:48:53] donauinsel at hotmail dot com
Description:
------------
Try first $month = 11,$year = 2007 then $month =12, $year = 2007
Function returns correct value which seems not to be passed correctly.
Reproduce code:
---------------
function fixdate(&$month, &$year) {
if ($month < 1) {
$month = 12;
$year--;
} elseif ($month > 12) {
$month = 1;
$year++;
}
}
fixdate($nextmonth = ($month + 1), $nextyear = ($year + 0));
Expected result:
----------------
12 / 2007 or 01 / 2008
Actual result:
--------------
you will get 13 / 2007 instead.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=42268&edit=1