View Single Post
Old 02-06-2005, 02:17 PM   #4 (permalink)
idx
Senior Grasshopper
 
idx's Avatar
 
Join Date: Jun 2003
Location: FL
Posts: 317
idx is on a distinguished road
Redhead has you covered there, but I'll be a syntax nazi for a bit..

- It's always good practice to put your literal first in a comparison to avoid this very scenario.
eg:
PHP Code:
if ('0000-00-00' $shipdate) {
   
$shipdate 'NONE';

So even if you use = instead of == it'll evaluate as false and you'll find the problem earlier. Plus, if you have a large conditional statement, your literal will be in at the front and easier to read.

- One-liners are never good for code maintainability.
Not very clear:
PHP Code:
if ('0000-00-00' == $shipdate)
   
$shipdate 'NONE';
   
func1();
   
func2();
   
//etc.. 

much better:
PHP Code:
if ('0000-00-00' == $shipdate) {
   
$shipdate 'NONE';
}
   
func1();
   
func2();
   
//etc.. 
-r
idx is offline   Reply With Quote