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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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: Fri Apr 26 08:01:30 2024 UTC