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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
7 + 29 = ?
Subscribe to this entry?

 
 [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: Tue Apr 16 21:01:28 2024 UTC