Re: function question

From: Date: Thu, 01 May 2003 21:24:22 +0000
Subject: Re: function question
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-146013@lists.php.net to get a copy of this message
Problem solved! Thanks John "John W. Holmes" <holmes072000@charter.net> wrote in message news:005e01c30fe5$0c4b1340$7c02a8c0@coconut... > > I am using a function mofied from an earlier post to check whether a > given > > date is valid and does not occur in the past, however when i try to > use > > the > > function with: > > > > if(futureDate($_POST[booking_date]) == 'weekend'){ > > echo 'date is a weekend' > > } > > > > and the function is returning zero, it still enters the loop and > prints > > 'date is a weekend' > > > > I would be grateful for your help as this doesn't make sense to me! > > > > Date checking function: > > > > function futureDate($timestamp){ > > $error = 0; > > Type juggling. Since the function is returning an integer, PHP is going > to convert 'weekend' to an integer and compare them. A string like > 'weekend' will be converted to zero, so the two will end up matching. > > Have your function return an empty string as the default error. > > $error = ''; > > ---John W. Holmes... > > PHP Architect - A monthly magazine for PHP Professionals. Get your copy > today. http://www.phparch.com/ > >

« previous php.general (#146013) next »