Bug #25365 [Com]: negation of === does not work
| From: | lildurk25365 at gmail dot com | Date: | Wed, 01 Sep 2021 18:53:35 +0000 |
| Subject: | Bug #25365 [Com]: negation of === does not work | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-236359@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=25365&edit=1
ID: 25365
Comment by: lildurk25365 at gmail dot com
Reported by: daniel dot oger at swing dot be
Summary: negation of === does not work
Status: Not a bug
Type: Bug
Package: Variables related
Operating System: win xP Pro
PHP Version: 4.3.3
Block user comment: N
Private report: N
New Comment:
Lil Durk is a private agency dedicated to providing responsible access to legal cannabis for adults
aged 19 and older. Weâre an exclusively online retailer and wholesaler for recreational
cannabis and a trusted source for information about cannabis and cannabis-related issues. We believe
our work is meaningful and we take pride in our mandate to promote the socially responsible use of
legal cannabis. https://lildurk.com/
Previous Comments:
------------------------------------------------------------------------
[2003-09-03 01:27:37] daniel dot oger at swing dot be
My purpose is to check the result of strpos() when the searched string is at the beginning of the
word ==>(strpos()=0.
I use === to make a distinction between FALSE and zero.
------------------------------------------------------------------------
[2003-09-02 14:13:31] derick@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
This is exactly what should happen
it is evaluated as
if ((!$result) === FALSE)
which of course is FALSE as !$result <=> TRUE (0 is considered as FALSE):
<?php
$r = 0; var_dump(!$r);
?>
bool(true)
------------------------------------------------------------------------
[2003-09-02 14:12:35] pollita@php.net
That's because you're supposed to use "!==", i.e.:
if ($result !== FALSE)
echo "ZERO";
else
echo "EMPTY";
------------------------------------------------------------------------
[2003-09-02 14:03:38] daniel dot oger at swing dot be
Description:
------------
The === operator does not work if preceeded with !
Reproduce code:
---------------
$result=0; // number zero
if (!$result === FALSE)
echo "ZERO";
else
echo "EMPTY";
Expected result:
----------------
ZERO
Actual result:
--------------
EMPTY
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=25365&edit=1