By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,405 Members | 1,531 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,405 IT Pros & Developers. It's quick & easy.

Strange if statement

P: n/a
if ($result)
$total = $result->RecordCount();

Is this if statement purely looking for the prescence of the variable of
$result before executing?

Cheers

Phil


Jul 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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

Jul 17 '05 #2

P: n/a
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

Jul 17 '05 #3

P: n/a
"Phil Latio" <ph********@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, ti**@probo.com
Providenza & Boekelheide, Inc.
Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.