php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39334 Value und type of var changes in if statement
Submitted: 2006-11-01 14:47 UTC Modified: 2006-11-01 15:08 UTC
From: sw4u at gmx dot net Assigned:
Status: Not a bug Package: Variables related
PHP Version: 4.4.4 OS: Debian Linux 3.1
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: sw4u at gmx dot net
New email:
PHP Version: OS:

 

 [2006-11-01 14:47 UTC] sw4u at gmx dot net
Description:
------------
Only the last var in an if statement with function call is returned as expected. The other types are changed to bool.

Debian Linux 3.1
Server API Apache 2.0 Handler
Default Debian installation
Apache/2.0.54 (Debian GNU/Linux) PHP/4.3.10-16


Reproduce code:
---------------
<?php

function test($string){
  return ($string);
}

if( $a = test("a") && $b = test("b") && $c = test("c") ){
  echo $a;
  echo $b;
  echo $c;
}

?>


Expected result:
----------------
abc

Actual result:
--------------
11c

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-11-01 15:08 UTC] johannes@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

Please check the operator precedence and use parenthesis. See php.net/operator
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 16:01:28 2024 UTC