|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2003-04-28 09:32 UTC] sniper@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 15:00:01 2025 UTC |
Ok... I'll try my best to explain the problem. I have the following function: function fixdate(&$month, &$year) { if ($month < 1) { $month = 12; $year--; } elseif ($month > 12) { $month = 1; $year++; } } So far so good, the function itself works ok. But when I try to do the following: fixdate($prevmonth = ($month - 1), $prevyear = $year); I get this error: Fatal error: Only variables can be passed by reference in C:\foo.php on line 181 However, this code works as expected: fixdate($prevmonth = ($month - 1), $prevyear = ($year + 0)); You'd expect the first code ($prevyear = $year) to work as well, wouldn't you? The reason I use $prevyear = $year and not just pass $year is because I need to keep the value of $year after the function has executed. This might be related to the way PHP copies variables, I'm not sure. If you need any more information, let me know. :) Thanks, Chen