Re: Are these two pieces of code equivalent

From: Date: Tue, 25 Jul 2000 13:03:39 +0000
Subject: Re: Are these two pieces of code equivalent
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-8024@lists.php.net to get a copy of this message
> > > if (pg_NumRows($result) > 0){ > > > $num = pg_NumRows($result); > > > echo $num; > > > > > Would result, for example, 10 > > > > > And > > > > > if ($num = pg_NumRows($result) > 0){ > > > echo $num > > > > > would also result, 10 ? > > > > The two pieces of code are equivalent. > Technically correct, but you will undoubtedly save yourself much time > debugging if you use: > if (($num = pg_NumRows($result)) > 0) > echo $num; > as errors in remembering associativity and precedence are a Leading > Cause of Hard-to-find Errors(tm). I agree 100%, the second form is by far the best one to use! Jesper Juhl juhl@eisenstein.dk

« previous php.general (#8024) next »