I am an experienced C++ programmer but am new to PHP and have some questions about variable typing.
In C++ you type all of your variables (int, short, long, double etc.) but in PHP it is my understanding that all variables are simply preceded by a $.
I am using PHP 4 so unfortunately exceptions are not allowed which means (like in C) you usually return success or failure rather than being allowed the luxury of using exceptions and returning what you will.
In short, my questions are ...
Can I return ... say FALSE from a PHP function if something fails, but in another place in the same function return ... say ... an array?
Also, how does this affect the variable that contains the return value (see below) since they are of different types (FALSE and array are different type)?
For example, consider this:
Foo is returning either A) FALSE, or B) an array.
Code: Select all
$Array = array();
if(FALSE == $Array = Foo())
{
return FALSE;
}
So ... in short ... I need to know if you can return values of different types from PHP functions, and how (like in the snippet above) one tests for equalities between values if they are of different types (in the above example $Array could then be assigned either FALSE or an array).
Thank you for your help.
Jeremy