php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25365 negation of === does not work
Submitted: 2003-09-02 14:03 UTC Modified: 2003-09-03 01:27 UTC
From: daniel dot oger at swing dot be Assigned:
Status: Not a bug Package: Variables related
PHP Version: 4.3.3 OS: win xP Pro
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: daniel dot oger at swing dot be
New email:
PHP Version: OS:

 

 [2003-09-02 14:03 UTC] 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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-09-02 14:12 UTC] 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:13 UTC] 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-03 01:27 UTC] 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.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Fri Feb 13 02:00:02 2026 UTC