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

Add a Patch

Pull Requests

Add a Pull Request

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: Sun Apr 28 23:01:32 2024 UTC