Only the first tests, if $sth is NULL, the value 0 will also be true. The second checks if the type is equal. Thus, the NULL value as the value for $sth will be true. The third will only work with variables, not function results.
Also a little hint: from time to time it occurs to me that I am mistaken if($sth == NULL) to if($sth = NULL) , which will make it difficult to find errors. Better enter if(NULL == $sth) , where you get an interpreter error when you write incorrectly, which will point you in the right direction.
source share