RE: [PHP] Help with " Function " parameter

From: Date: Fri, 05 Apr 2002 00:39:06 +0000
Subject: RE: [PHP] Help with " Function " parameter
Groups: php.general 
Request: Send a blank email to php-general+get-91648@lists.php.net to get a copy of this message
Your problem lies in these lines Return $realday; Return $month; Return $year; and Datereturn(); A function can only return one "value" - that value can be an array (see later) To use the returned value, you need to assign it to something (or use it directly) So, change your return to this: Return array($realday, $month, $year); and then change this line Datereturn(); to either $tmp = Datereturn(); $realday = $tmp[0]; $month = $tmp[1]; $year = $tmp[2]; Or this (which I think is a better way) list($realday, $month, $year) = Datereturn(); HTH Martin -----Original Message----- From: Simonk [mailto:fong@btinternet.com] Sent: Friday, April 05, 2002 1:21 AM To: php-general@lists.php.net Subject: [PHP] Help with " Function " parameter I have programed a function for counting Date: function Datereturn() { $monthorder = Array ( 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); $day = Date("j"); $monthday = Date("t"); $month = Date("n"); $year = Date("Y"); $current = 42 - ($monthday - $day); if ($current > $monthorder[$month]) { $realday = $current - $monthorder[$month]; $month = $month + 2; if ($month > 12) { $year = $year + 1; $month = $month - 12; } } else { $realday = $current; $month = $month + 1; if ($month > 12) { $year = $year + 1; $month = $month - 12; } } Return $realday; Return $month; Return $year; } But when I want to echo out the result, I have typed: Datereturn(); echo "$year, $month, $realday"; Then the server return: Undefined variable year, month, realday plz help! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general (#91648) next »