php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #55092 settype bug
Submitted: 2011-06-30 17:11 UTC Modified: 2011-07-01 03:16 UTC
From: brent_hathaway at yahoo dot com Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 5.3.6 OS: Linux
Private report: No CVE-ID: None
 [2011-06-30 17:11 UTC] 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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-07-01 03:16 UTC] aharvey@php.net
-Status: Open +Status: Bogus
 [2011-07-01 03:16 UTC] aharvey@php.net
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.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Dec 02 10:00:01 2025 UTC