Re: Are these two pieces of code equivalent
| From: | Andreas Pour | Date: | Tue, 25 Jul 2000 12:16:36 +0000 |
| Subject: | Re: Are these two pieces of code equivalent | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-8014@lists.php.net to get a copy of this message | ||
Jesper Juhl wrote:
>
> > I would like to know if these pieces of code are equivalent:
>
> > 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).
Ciao,
Andreas