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
 [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-2019 The PHP Group
All rights reserved.
Last updated: Thu Nov 14 07:01:35 2019 UTC