Re: PHP 4.0 Bug #5537: problem with value false returning from strpos() function

From: Date: Tue, 11 Jul 2000 22:37:19 +0000
Subject: Re: PHP 4.0 Bug #5537: problem with value false returning from strpos() function
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-24232@lists.php.net to get a copy of this message
Try using === operator equal value and type. On 12 Jul 2000 sat@3wdesign.es wrote: > From: sat@3wdesign.es > Operating system: Linux Debian 2.1 > PHP version: 4.0.0 > PHP Bug Type: Other > Bug description: problem with value false returning from strpos() function > > <? > $string = "FOO STRING"; > $string1 = "FOO"; > $string2 = "OO"; > $string3 = "ZOO"; > > $value1 = strpos($string,$string1,0); > $value2 = strpos($string,$string2,0); > $value3 = strpos($string,$string3,0); > > for ($i=1;$i<=3;$i++) { > if (${value.$i}>=0) { > echo "string".$i." found at:".${value.$i}."<br>"; > } > elseif (${value.$i}==FALSE) { > echo "string".$i." not found.<br>"; > } > } > > ?> > > $value3>=0 and $value3==FALSE are equivalent and so we can not distinguish between > string found at position 0 and string not found. > > strpos should return -1 when the string was not found. > > > -- > PHP Development Mailing List <http://www.php.net/> > To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net > For additional commands, e-mail: php-dev-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.dev (#24232) next »