This is a discussion on Strange if statement within the PHP Language forums, part of the PHP Programming Forums category; if ($result) $total = $result->RecordCount(); Is this if statement purely looking for the prescence of the variable of $result ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Phil Latio wrote:
> if ($result) > $total = $result->RecordCount(); > > Is this if statement purely looking for the prescence of the variable of > $result before executing? > No, it's checking whether the value of $result evaluates to boolean TRUE. See http://www.php.net/manual/types.comparisons.php -- Oli |
|
|||
|
Basically it's making sure that $result is not the following values:
0 '' FALSE (null) Databases have a habit of returning FALSE or (null) when they encounter an error. Essentially, this is a check to see if the query executed properly. ~D |
|
|||
|
"Phil Latio" <phil.latio@f-in-stupid.co.uk> wrote:
> >if ($result) >$total = $result->RecordCount(); > >Is this if statement purely looking for the prescence of the variable of >$result before executing? Presence, maybe, or perhaps a "null" error result from some API. -- - Tim Roberts, timr@probo.com Providenza & Boekelheide, Inc. |