php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71933 Is_int() applied a float cast is incorrect
Submitted: 2016-03-31 15:29 UTC Modified: 2016-03-31 15:42 UTC
From: daniel dot gimeno at gmail dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 5.6.19 OS: Ubuntu 14.04
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: daniel dot gimeno at gmail dot com
New email:
PHP Version: OS:

 

 [2016-03-31 15:29 UTC] daniel dot gimeno at gmail dot com
Description:
------------
The problem is when a float cast it's applied to a variable.

Does not matter what is the value of that variable, is_int() will always return a False result.


Test script:
---------------
$num  = (float)2; //it's the same result for 0, 2, 2.0 or 2.3
$isint = is_int($num);
var_dump ($num);
var_dump($isint);

You get:

float(2)
bool(false)


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-03-31 15:42 UTC] krakjoe@php.net
-Status: Open +Status: Not a bug
 [2016-03-31 15:42 UTC] krakjoe@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 15 05:01:33 2025 UTC