Edit report at http://bugs.php.net/bug.php?id=52919&edit=1

 ID:                 52919
 Updated by:         [email protected]
 Reported by:        ghazanfar dot ahmed at magsnet dot net
 Summary:            if does not work properly of strlen even if
                     typecasted
 Status:             Open
 Type:               Bug
 Package:            Scripting Engine problem
 Operating System:   Centos 5.5
 PHP Version:        Irrelevant
 Block user comment: N

 New Comment:

This makes no sense... No way to reproduce such thing.


Previous Comments:
------------------------------------------------------------------------
[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

Reply via email to