php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #50132 a bug(?) in the time() function
Submitted: 2009-11-09 22:47 UTC Modified: 2009-11-09 23:15 UTC
From: saber_lowbob at live dot de Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 5.2.11 OS: Windows Vista SP1
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: saber_lowbob at live dot de
New email:
PHP Version: OS:

 

 [2009-11-09 22:47 UTC] saber_lowbob at live dot de
Description:
------------
a bug(?) in the time() function

Reproduce code:
---------------
    function isInt($string) {
        $string = preg_replace('[0-9]','',$string);
        if($string == '') {
            return true;
        } else {
            return false;
        }
    }

    if(isInt(time())) {
        echo "is Int";
    } else {
        echo "is not Int";
    }

Expected result:
----------------
is Int

Actual result:
--------------
is not Int

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-11-09 22:51 UTC] rasmus@php.net
Did you do any debugging at all to see why you might be getting that result?

Hint, your regex string in the preg_replace() call is wrong.
 [2009-11-09 23:06 UTC] saber_lowbob at live dot de
the regex is right.. I'm sorting out all letters and checking if something's left in the string.. if not -> true
 [2009-11-09 23:15 UTC] saber_lowbob at live dot de
nevermind, I found the error.. I think I've been up too long to do such a stupid mistake
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 02 16:01:29 2024 UTC