php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #12245 gettype(true && true) returns "integer"!
Submitted: 2001-07-19 05:56 UTC Modified: 2001-08-30 08:12 UTC
From: nick at macaw dot demon dot co dot uk Assigned: jeroen (profile)
Status: Closed Package: Variables related
PHP Version: 4.0.6 OS: Solaris
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: nick at macaw dot demon dot co dot uk
New email:
PHP Version: OS:

 

 [2001-07-19 05:56 UTC] nick at macaw dot demon dot co dot uk
The && operator (and ||) returns an integer value even when both arguments are boolean. Thus the following code:

function is_true($val)
{
   return (is_bool($val) && $val);
}

echo (is_true(true) ? 'T' : 'F'),"\n";
echo (is_true(is_true(true)) ? 'T' : 'F'),"\n";

gives

T
F

-- Nick


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-08-08 19:12 UTC] jeroen@php.net
KISS example:

var_dump(TRUE || TRUE) -> int(1)
var_dump(FALSE && FALSE) -> int(0)

Patch awaiting to be committed, will be fixed in 4.0.7


 [2001-08-19 05:14 UTC] sniper@php.net
added missing 'Assign To:' info.

 [2001-08-30 08:12 UTC] jeroen@php.net
Fixed in 4.0.7
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 27 22:01:28 2024 UTC