Re: Simple question that I can't find the answer to

From: Date: Sat, 13 Jan 2001 22:57:18 +0000
Subject: Re: Simple question that I can't find the answer to
References: 1 2 3  Groups: php.windows 
Request: Send a blank email to php-windows+get-4986@lists.php.net to get a copy of this message
All of these "tricks" to exchange the contents of two variables, while possessing a certain elegance, share one common defect. They are tricky. Days, weeks and months later they can and likely will be difficult to understand. This kind of trickiness may have a place deep in the internals of a package such as PHP or an OS kernel, but in a routine to edit user inputs clarity is probably a more important virtue. I suggest the best way to handle the situation originally posted would be something like: if $userFromDate > $userToDate { $sqlFromDate = $userToDate; $sqlToDate = $userFromDate; } else { $sqlToDate = $userToDate; $sqlFromDate = $userFromDate; } "Tricks" obviously do make interesting discussion topics though. ~~LF ----- Original Message ----- From: Sean Bright To: php-windows@lists.php.net Sent: Saturday, January 13, 2001 10:01 AM Subject: Re: [PHP-WIN] Simple question that I can't find the answer to Yeah, but you could run into overflow problems with large values of a and b. Sean Jan Walter wrote: > > If you are working with numbers, which is perhaps not your case, you can use > this simple trick to swith values of $a and $b: > > $a = $a + $b; > $b = $a - $b; > $a = $a - $b; > -- > __________________________________________________________________________________________ > > ========================================================================================== > > Jan Walter, called John > LERACH, s.r.o. > phone nr. work: +420-2-78 22 619, home: +420-2-35 35 27 61 > on emergency call cell phone: +420-602-385 760 > work e-mail mailto:Jan.Walter@lerach.cz > private e-mail mailto:john@lerach.cz > ICQ#: 28353428 > __________________________________________________________________________________________ > > ========================================================================================== > > -- > PHP Windows Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-windows-unsubscribe@lists.php.net > For additional commands, e-mail: php-windows-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net -- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-windows-unsubscribe@lists.php.net For additional commands, e-mail: php-windows-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.windows (#4986) next »