note 25510 added to language.operators.comparison

From: Date: Thu, 26 Sep 2002 08:49:32 +0000
Subject: note 25510 added to language.operators.comparison
Groups: php.notes 
Request: Send a blank email to php-notes+get-37269@lists.php.net to get a copy of this message
A good example for using the "===" operator. Check this out: if (strpos($a, $b) === 0) { ... } evaluates true exactly when $a *begins* with $b, i.e. if strpos returns Zero. And why "===" ? Because if $b is not at all contained in $a, strpos will return "false", which evaluates to "0" if compared to another numeric. Now, "===" does not only compare the values but also the type, and since 'false' is of a different type than "0", you'll get the result you expect. Cool, eh? Have fun! /sascha -- http://www.php.net/manual/en/language.operators.comparison.php http://master.php.net/manage/user-notes.php?action=edit+25510 http://master.php.net/manage/user-notes.php?action=delete+25510 http://master.php.net/manage/user-notes.php?action=reject+25510

« previous php.notes (#37269) next »