[PHP-DEV] PHP 4.0 Bug #4202: if interprets "0" as "false" even when checking for "numeric value" vs "false" From: shh <email protected>
Date: 04/20/00

From: shh <email protected>
Operating system: Red Hat Linux 6.2
PHP version: 4.0 Release Candidate 1
PHP Bug Type: Misbehaving function
Bug description: if interprets "0" as "false" even when checking for "numeric value" vs "false"

Here is a script that reproduces the problem:

$string_1="<test>";
$string_2="test";
print("strrpos returns: \"".strrpos($string_1,"<")."\"<br>");
if(strrpos($string_1,"<")=="0") print "string_1 if is true<br>"; else print "string_1 if is false<br>";
print("strrpos returns: \"".strrpos($string_2,"<")."\"<br>");
if(strrpos($string_2,"<")=="0") print "string_2 if is true<br>"; else print "string_2 if is false<br>";

When run on PHP-4, Apache 1.3.12, Red Hat Linux 6.2 the output is:

strrpos returns: "0"
string_1 if is true
strrpos returns: ""
string_2 if is true <---- This should be false!

When run on PHP-3, Apache 1.3.11, Red Hat Linux 6.1 the output is:

strrpos returns: "0"
string_1 if is true
strrpos returns: ""
string_2 if is false

PHP was configured using ./configure --with-pgsql=/usr/local/pgsql --with-apache=../apache_1.3.12 --enable-track-vars

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: php-dev-unsubscribe <email protected>
For additional commands, e-mail: php-dev-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>