NYCPHP Meetup

NYPHP.org

[nycphp-talk] Question Using If's and Possible Arrays

IAlsoAgree at stny.rr.com IAlsoAgree at stny.rr.com
Tue Jan 17 20:20:03 EST 2006


I have a question about using if statements with variables that are
sometimes arrays and sometimes not arrays.

I have a function that returns either the contents of a database row or
false.
For example:
$variable = callfunction()

In this case, callfunction would either return the contents of a row in
a database or simply false.

Lets assume that, for instances of this question, callfunction returns
false and $variable is now equal to false.
function callfunction()
 {
  return false;
 }

If I then use:
if ($variable['alias'])

Will the if statement result in false because that is the only value of
$variable (noting that $variable has NOT been initiated as an array,
this is the first time it has been refrenced as an array)?

-Joe





More information about the talk mailing list