Edit report at http://bugs.php.net/bug.php?id=52694&edit=1

 ID:                 52694
 User updated by:    biolizard dot mail at gmail dot com
 Reported by:        biolizard dot mail at gmail dot com
 Summary:            Or operator inconsistency
 Status:             Bogus
 Type:               Bug
 Package:            Scripting Engine problem
 Operating System:   Linux Fedora 13
 PHP Version:        5.3.3
 Block user comment: N

 New Comment:

I apologize for the inconvenience.


Previous Comments:
------------------------------------------------------------------------
[2010-08-25 09:14:21] ras...@php.net

It follows the operator precedence rules documented here: 

http://php.net/manual/en/language.operators.precedence.php



OR and || are obviously not synonymous.  Your examples match the
documented 

precedence table.

------------------------------------------------------------------------
[2010-08-25 09:11:13] biolizard dot mail at gmail dot com

Description:
------------
The logical operator 'or' and the operator '||' produce different
values, which 

is inconsistent with the description and the examples presented in the
PHP 

website. However, when returning from a function, the inconsistency is
even more 

problematic. The operator 'or', when used in a statement (e.g.,
assignment), 

returns the first value that is not false. However, when used as a
return 

expression the returned value is either true or false.

Test script:
---------------
<?php



function f() {

  return 'ola' || 'adeus';

}



function p() {

  return 'ola' or 'adeus';

}



$a = 'ola' || 'adeus';

$b = 'ola' or 'adeus';



echo $a . "\n";

echo $b . "\n";



echo f() . "\n";

echo p() . "\n";



?>



Expected result:
----------------
1

ola

1

ola



Actual result:
--------------
1

ola

1

1




------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=52694&edit=1

Reply via email to