Bug #55092 [Opn->Bgs]: settype bug

From: Date: Fri, 01 Jul 2011 07:16:11 +0000
Subject: Bug #55092 [Opn->Bgs]: settype bug
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-161446@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=55092&edit=1

 ID:                 55092
 Updated by:         aharvey@php.net
 Reported by:        brent_hathaway at yahoo dot com
 Summary:            settype bug
-Status:             Open
+Status:             Bogus
 Type:               Bug
 Package:            Unknown/Other Function
 Operating System:   Linux
 PHP Version:        5.3.6
 Block user comment: N
 Private report:     N

 New Comment:

settype() returns true or false, not the modified variable: it takes the given 
variable by reference and modifies it in-place. As a result, you're testing the 
return value (which is expected to be boolean) and not the modified $z, which is 
overwritten.


Previous Comments:
------------------------------------------------------------------------
[2011-06-30 17:11:26] brent_hathaway at yahoo dot com

Description:
------------
---
From manual page: http://www.php.net/function.settype
---
The version is actually 5.3.5 but is not in the dropdown


When using settype on an integer it will not respond as an integer in is_int.

Test script:
---------------
$z = 5;    //int by default
$z = settype($z,"int");    //unneeded but shows bug
if (is_int($z)) {
    echo "int";
} else {
    echo "not int"; 
}

//output: not int

use instead:
$z = intval($z);  //output: int


Expected result:
----------------
int

Actual result:
--------------
not int


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=55092&edit=1


Thread (2 messages)

« previous php.bugs (#161446) next »