Bug #52919 [Bgs->Opn]: if does not work properly of strlen even if typecasted
| From: | cataphract@php.net | Date: | Fri, 24 Sep 2010 02:01:02 +0000 |
| Subject: | Bug #52919 [Bgs->Opn]: if does not work properly of strlen even if typecasted | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-154604@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=52919&edit=1
ID: 52919
Updated by: cataphract@php.net
Reported by: ghazanfar dot ahmed at magsnet dot net
Summary: if does not work properly of strlen even if
typecasted
-Status: Bogus
+Status: Open
Type: Bug
Package: Scripting Engine problem
Operating System: Centos 5.5
PHP Version: Irrelevant
Block user comment: N
New Comment:
Sorry, I didn't read the comment. Re-opened.
Previous Comments:
------------------------------------------------------------------------
[2010-09-24 03:36:23] cataphract@php.net
Expected behavior. 3 > 7 is false, hence the else block will be
executed...
------------------------------------------------------------------------
[2010-09-23 23:54:27] felipe@php.net
This makes no sense... No way to reproduce such thing.
------------------------------------------------------------------------
[2010-09-23 22:50:34] ghazanfar dot ahmed at magsnet dot net
Sorry, it prints "CHECK IF" where it should print "CHECK ELSE"
------------------------------------------------------------------------
[2010-09-23 22:46:23] ghazanfar dot ahmed at magsnet dot net
Description:
------------
IF does not produce correct result when strlen is used to calculate
length of a
string which is an integer
Test script:
---------------
//IF does not seem to evaluate properly
$row['number'] = 700; //in my case if was value retrieved from mysql
// force typecasting
$number = (string)$row['number'];
if(strlen(trim($number)) > 7) {
print "CHECK IF"; }
else {
print "CHECK ELSE";
}
//It will always print "CHECK ELSE" where strlen($number)=3 (computes
correctly)
// where 3 > 7 is false
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=52919&edit=1