php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42662 function no execution in if condition
Submitted: 2007-09-13 17:36 UTC Modified: 2007-09-17 18:54 UTC
From: thug at thug dot fr Assigned:
Status: Closed Package: Unknown/Other Function
PHP Version: 5.2.4 OS: win XP
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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: thug at thug dot fr
New email:
PHP Version: OS:

 

 [2007-09-13 17:36 UTC] thug at thug dot fr
Description:
------------
When using a function in a if() condition, the function is not always launched.

Reproduce code:
---------------
if(	!$something && !aff_new_com('news', $last_time) && !aff_new_com('ftp', $last_time) )


Expected result:
----------------
if( $bool && fct($a) && fct($b))
Then fct($a) and  fct($b) are not launched

if( funcct($a) && $bool && fct($b))
Then fct($a) is launched but not fct($b)

fct return always true or false


Actual result:
--------------
All functions in the if should be launched.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-09-16 23:29 UTC] carsten_sttgt at gmx dot de
First one question:
You have interchanged expected and actual result?

If yes, that's the correct behaviour:
If the first expression from the AND operator evaluate the FALSE, it make's no sense to test the rest, because the complete statement can't be TRUE anymore. (with the AND/&& operator all expressions must be true)

e.g.:
| if( $bool && fct($a) && fct($b))
- Only if $bool == true, fct($a) will be executed
- Only if $bool == true and fct($a) returns true, fct($b) will be executed
 [2007-09-17 18:54 UTC] thug at thug dot fr
OK, y am sorry... I think that all functions of if expression should executed.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 10:01:28 2024 UTC