php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #37881 Flow error (&= (boolexpr))
Submitted: 2006-06-22 05:10 UTC Modified: 2006-06-22 08:51 UTC
From: freebsd at akruijff at dds dot nl Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 5.1.4 OS: FreeBSD
Private report: No CVE-ID: None
 [2006-06-22 05:10 UTC] freebsd at akruijff at dds dot nl
Description:
------------
Combining operaters fail when combining the sort version of the bit operator + boolean expression

i.e. $flags &= ($msg != '');

Reproduce code:
---------------
  $msg = 'xxx';
  $flags = 0;
  $flags &= ($msg != '');
  echo $flags;
  $flags &= ($msg != '') ? 1 : 0;
  echo $flags;
  $flags &= (($msg != '') ? 1 : 0);
  echo $flags;


Expected result:
----------------
111

Actual result:
--------------
000

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-06-22 08:51 UTC] mgf@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

Your Boolean logic is wrong: 0 & 1 gives 0, not 1.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 17 14:04:04 2025 UTC