|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #19575 Boolean prints 1 for TRUE but nothing for FALSE
Submitted: 2002-09-24 06:56 UTC Modified: 2002-11-04 05:04 UTC
From: jc at mega-bucks dot co dot jp Assigned: goba (profile)
Status: Closed Package: Documentation problem
PHP Version: 4.2.3 OS: Red Hat Linux 7.2
Private report: No CVE-ID: None
 [2002-09-24 06:56 UTC] jc at mega-bucks dot co dot jp
A boolean of TRUE will print as "1" whereas FALSE prints as "" 

This has caused me a problem since I had assume that TRUE would print as TRUE and FALSE would print as FALSE.

Could you add this to the documentation. I could understand 1/0, TRUE/FALSE, but "1"/"" is not evident at first.

I'd even suggest a change request that booleans print out as TRUE/FALSE (since booleans really should not be 1/0 integers or empty/non-empty strings but BOOLEANS) but I'm sure that would ge  shot down. :)


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-10-05 09:58 UTC]
Dupe of bug #18411
 [2002-10-05 10:04 UTC]
This feature(!) is there so you can convert from booleans to strings, then back to booleans or to integers and then to booleans, and you get the same boolean you started from...

boolean -> string -> boolean
 TRUE        "1"       TRUE
 FALSE       ""        FALSE

boolean -> string -> integer -> boolean
 TRUE        "1"        1         TRUE
 FALSE       ""         0         FALSE

In php code:

  $false_bool = (boolean) (int) (string) FALSE;

 [2002-10-06 21:25 UTC] jc at mega-bucks dot co dot jp

I understand the need for such a feature I just don't like the implementation. But hey, I don't like loosely typed languaged in the first place ;)

But ... all I'm asking for is better documentation. I didn't expect this behaviour and couldn't find any documentation to help figureout why what I was not expecting was happening.
 [2002-10-07 01:58 UTC]
I'll correct this sometime later if noone picks it up. I have no time now, sorry.
 [2002-11-04 05:04 UTC]
I have just fixed this, it will show up in some days on the PHP site...
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Mon Sep 26 09:05:56 2022 UTC