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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Wed May 07 11:01:29 2025 UTC