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: [EMAIL PROTECTED] 
  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:[EMAIL PROTECTED]
  > private e-mail mailto:[EMAIL PROTECTED]
  > ICQ#: 28353428
  > 
__________________________________________________________________________________________
  > 
  > 
==========================================================================================
  > 
  > --
  > PHP Windows Mailing List (http://www.php.net/)
  > To unsubscribe, e-mail: [EMAIL PROTECTED]
  > For additional commands, e-mail: [EMAIL PROTECTED]
  > To contact the list administrators, e-mail: [EMAIL PROTECTED]

  -- 
  PHP Windows Mailing List (http://www.php.net/)
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to