php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #10162 different behaviour of && and and operator
Submitted: 2001-04-04 11:59 UTC Modified: 2001-04-04 12:04 UTC
From: gerald dot kallas at web dot de Assigned:
Status: Closed Package: Unknown/Other Function
PHP Version: 4.0.4 OS: Windows 2000 Professional
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: gerald dot kallas at web dot de
New email:
PHP Version: OS:

 

 [2001-04-04 11:59 UTC] gerald dot kallas at web dot de
in the case shown below both operators generate different values, once TRUE twice FALSE

source code

<?php
function isValid_and($a)
  {
  $valid = true;
  $b = 1;
  
  $valid = $valid and (strlen($a) >= $b);
  
  return $valid;
  }

function isValid_and_($a)
  {
  $valid = true;
  $b = 1;
  
  $valid = $valid && (strlen($a) >= $b);
  
  return $valid;
  }

$a = "";

if (isValid_and($a))
  echo "and - true<br/>";
else
  echo "and - false<br/>";

if (isValid_and_($a))
  echo "&& - true<br/>";
else
  echo "&& - false<br/>";
?>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-04-04 12:04 UTC] sniper@php.net
Please check this manual page:

http://www.php.net/manual/en/language.operators.precedence.php

Not a bug.

--Jani

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 23 01:01:32 2024 UTC