Bug #79592 [Nab]: Converting string to bool when "0" passed

From: Date: Wed, 13 May 2020 15:39:04 +0000
Subject: Bug #79592 [Nab]: Converting string to bool when "0" passed
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-227027@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79592&edit=1

 ID:                 79592
 Updated by:         cmb@php.net
 Reported by:        6562680 at gmail dot com
 Summary:            Converting string to bool when "0" passed
 Status:             Not a bug
 Type:               Bug
 Package:            Filter related
 Operating System:   Win10
 PHP Version:        7.3.17
 Block user comment: N
 Private report:     N

 New Comment:

The point is, that even if we wanted to change this, we can't for
backward compatibility reasons.

Thanks.


Previous Comments:
------------------------------------------------------------------------
[2020-05-13 15:10:02] bugreports at gmail dot com

> Damn,
>
> $var = '0';
> empty($var); // true

damn guess hwat - it's consistent

'0' == 0 == FALSE

nobody right in his mind expects anything else when it comes to https://www.php.net/manual/de/language.types.type-juggling.php
and that you refuse to understand language basics by insist it's a bug is a hint that you
should refrain from programming to be honest

------------------------------------------------------------------------
[2020-05-13 15:05:56] bugreports at gmail dot com

come on and fix your expectations given nobody but you expects "0" and 0 which is
practically the same when it comes to type juggling evaluate to true

0/1 is the same as true/false, with or without you when it comes too lose types

------------------------------------------------------------------------
[2020-05-13 14:00:28] 6562680 at gmail dot com

Damn,

$var = '0';
empty($var); // true

Even there...

------------------------------------------------------------------------
[2020-05-13 13:58:56] 6562680 at gmail dot com

You know, guys, documentation is like exception - it is delayed uncoded solution for the problem.

Good application never thrown exception. But as one coder you cant hold in your mind all possible
exceptions so you throw it for future fixing.

The community imagine "documentation" word like "we just write there is a bug and it
is not a bug. we're done"

------------------------------------------------------------------------
[2020-05-12 21:18:46] girgias@php.net

This is documented behaviour, if you want a reason why this behaves like this imagine it being
converted to an integer first and then converted to a boolean (because in effect a boolean is just
an integer that is 0 for false and anything else for true).

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=79592


--
Edit this bug report at https://bugs.php.net/bug.php?id=79592&edit=1


Thread (7 messages)

« previous php.bugs (#227027) next »