The Context of 0

From: Date: Tue, 02 Oct 2007 17:14:42 +0000
Subject: The Context of 0
Groups: php.general 
Request: Send a blank email to php-general+get-262647@lists.php.net to get a copy of this message
[small rant] This morning's thread on strpos() brings up an interesting point, zero has a context. In certain cases 0 is the equivalent of FALSE and in other cases a 0 is just a 0. In the context of strpos() 0 indicates that the needle is in the first position of the haystack. If the needle is not found in the haystack a Boolean FALSE is returned. In this case 0 is not the equivalent of FALSE. There are other cases, most of them specific to strings, in which 0 is not the equivalent of FALSE. Newbies to PHP or certain functions will no doubt encounter these cases at some point. Exercise care when using 0 to determine if something is FALSE and understand that 0 has context. [/small rant]

« previous php.general (#262647) next »