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
 [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

Pull Requests

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: Tue Dec 10 00:01:28 2024 UTC