PHP 4.0 Bug #4202: if interprets "0" as "false" even when checking for "numeric value" vs "false"
| From: | shh at enovia dot com | Date: | Thu, 20 Apr 2000 17:53:26 +0000 |
| Subject: | PHP 4.0 Bug #4202: if interprets "0" as "false" even when checking for "numeric value" vs "false" | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-18065@lists.php.net to get a copy of this message | ||
From: shh@enovia.com
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