From:             terminatorul at gmail dot com
Operating system: 
PHP version:      Irrelevant
PHP Bug Type:     Documentation problem
Bug description:  Side-effects for logical operators

Description:
------------
The manual page for logical operators

http://www.php.net/manual/en/language.operators.logical.php

should warn users that the right-hand operand of && or ||
will never be evaluated if that is not necesary

For example when doing:

$result = FALSE && mysql_query($query);

than the mysql $query will never get executed.

Or at least the page should advise users to never rely on side-effects.

Reproduce code:
---------------
http://www.php.net/manual/en/language.operators.logical.php

Expected result:
----------------
The page should say something like:

For the binary logical operators the second operand will never be
evaluated when it is clear from the first operand what the result will be.

For example the code

$prev_status = FALSE;
$crt_status = $prev_status && mysql_query($query);
echo mysql_affected_rows();

will never execute the query, simply because $crt_status will be FALSE no
matter what mysql_query() would return.

Actual result:
--------------
Right now I can see nothing about side-effects in the page.

-- 
Edit bug report at http://bugs.php.net/?id=41228&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=41228&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=41228&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=41228&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=41228&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=41228&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=41228&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=41228&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=41228&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=41228&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=41228&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=41228&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=41228&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=41228&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=41228&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=41228&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=41228&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=41228&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=41228&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=41228&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=41228&r=mysqlcfg

Reply via email to