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
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: 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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 15 05:01:33 2025 UTC