Ask a Question related to PHP Bugs, Design and Development.
-
milman at gmx dot de #1
#40669 [NEW]: problem with ternary operateor
From: milman at gmx dot de
Operating system:
PHP version: 5.2.1
PHP Bug Type: Scripting Engine problem
Bug description: problem with ternary operateor
Description:
------------
$a = 1 + (1) ? 2 : 5 ;
should be the same as
$a = 1 + ((1) ? 2 : 5);
as
$a = 3 ;
Reproduce code:
---------------
<?php
echo "<body><xmp>\n" ;
$a = 1 + (1) ? 2 : 5 ;
echo "wrong: $a\n" ;
$a = 1 + ((1) ? 2 : 5);
echo "right: $a\n" ;
echo "</xmp></body>\n" ;
?>
Expected result:
----------------
wrong: 3
right: 3
Actual result:
--------------
wrong: 2
right: 3
--
Edit bug report at [url]http://bugs.php.net/?id=40669&edit=1[/url]
--
Try a CVS snapshot (PHP 4.4): [url]http://bugs.php.net/fix.php?id=40669&r=trysnapshot44[/url]
Try a CVS snapshot (PHP 5.2): [url]http://bugs.php.net/fix.php?id=40669&r=trysnapshot52[/url]
Try a CVS snapshot (PHP 6.0): [url]http://bugs.php.net/fix.php?id=40669&r=trysnapshot60[/url]
Fixed in CVS: [url]http://bugs.php.net/fix.php?id=40669&r=fixedcvs[/url]
Fixed in release: [url]http://bugs.php.net/fix.php?id=40669&r=alreadyfixed[/url]
Need backtrace: [url]http://bugs.php.net/fix.php?id=40669&r=needtrace[/url]
Need Reproduce Script: [url]http://bugs.php.net/fix.php?id=40669&r=needscript[/url]
Try newer version: [url]http://bugs.php.net/fix.php?id=40669&r=oldversion[/url]
Not developer issue: [url]http://bugs.php.net/fix.php?id=40669&r=support[/url]
Expected behavior: [url]http://bugs.php.net/fix.php?id=40669&r=notwrong[/url]
Not enough info: [url]http://bugs.php.net/fix.php?id=40669&r=notenoughinfo[/url]
Submitted twice: [url]http://bugs.php.net/fix.php?id=40669&r=submittedtwice[/url]
register_globals: [url]http://bugs.php.net/fix.php?id=40669&r=globals[/url]
PHP 3 support discontinued: [url]http://bugs.php.net/fix.php?id=40669&r=php3[/url]
Daylight Savings: [url]http://bugs.php.net/fix.php?id=40669&r=dst[/url]
IIS Stability: [url]http://bugs.php.net/fix.php?id=40669&r=isapi[/url]
Install GNU Sed: [url]http://bugs.php.net/fix.php?id=40669&r=gnused[/url]
Floating point limitations: [url]http://bugs.php.net/fix.php?id=40669&r=float[/url]
No Zend Extensions: [url]http://bugs.php.net/fix.php?id=40669&r=nozend[/url]
MySQL Configuration Error: [url]http://bugs.php.net/fix.php?id=40669&r=mysqlcfg[/url]
milman at gmx dot de Guest
-
#25841 [Opn->Bgs]: ternary returns by-value rather than by-reference, although if/else works fine
ID: 25841 Updated by: sniper@php.net Reported By: pluggz24 at yahoo dot com -Status: Open +Status: ... -
#25841 [NEW]: ternary returns by-value rather than by-reference, although if/else works fine
From: pluggz24 at yahoo dot com Operating system: Slackware Linux 8.1, Windows XP PHP version: 4.3.2 PHP Bug Type: ... -
Problem playing Quicktime thru .DCR embedded in HTML - pathreferencing problem?
Greetings earthlings and Director heads. Here's the problem: created an HTML file containing shockwave (dcr) movie that calls quicktime movies in... -
#21611 [Opn]: Problem with version_compare() (Was: Problem with pear cli and release numbers)
ID: 21611 Updated by: et@php.net -Summary: Problem with pear cli and release numbers Reported By: jan at horde... -
Problem with Apache Web Server config file and PHP (please give advice on what problem may be me)
HI: Can anyone refer me to someone that can help with the problem below. I installed Apache Web Server on my laptop which has Windows XP. I... -
tony2001@php.net #2
#40669 [Opn->Bgs]: problem with ternary operateor
ID: 40669
Updated by: [email]tony2001@php.net[/email]
Reported By: milman at gmx dot de
-Status: Open
+Status: Bogus
Bug Type: Scripting Engine problem
PHP Version: 5.2.1
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
[url]http://www.php.net/manual/[/url] and the instructions on how to report
a bug at [url]http://bugs.php.net/how-to-report.php[/url]
[url]http://www.php.net/manual/en/language.operators.php[/url]
Previous Comments:
------------------------------------------------------------------------
[2007-02-28 18:36:03] milman at gmx dot de
Description:
------------
$a = 1 + (1) ? 2 : 5 ;
should be the same as
$a = 1 + ((1) ? 2 : 5);
as
$a = 3 ;
Reproduce code:
---------------
<?php
echo "<body><xmp>\n" ;
$a = 1 + (1) ? 2 : 5 ;
echo "wrong: $a\n" ;
$a = 1 + ((1) ? 2 : 5);
echo "right: $a\n" ;
echo "</xmp></body>\n" ;
?>
Expected result:
----------------
wrong: 3
right: 3
Actual result:
--------------
wrong: 2
right: 3
------------------------------------------------------------------------
--
Edit this bug report at [url]http://bugs.php.net/?id=40669&edit=1[/url]
tony2001@php.net Guest
-
milman at gmx dot de #3
#40669 [Bgs]: problem with ternary operateor
ID: 40669
User updated by: milman at gmx dot de
Reported By: milman at gmx dot de
Status: Bogus
Bug Type: Scripting Engine problem
PHP Version: 5.2.1
New Comment:
sorry, but i dosn't understand.
why must i write
$a = 1 + ((1) ? 2 : 5);
and
$a = 1 + (1) ? 2 : 5 ;
get a wrong result.
that is totaly unexpected.
i think it is to easy to say in documentation you should use
() with ternary operator.
than it should get a syntax-error when using without in expressions.
but not a wrong result.
Previous Comments:
------------------------------------------------------------------------
[2007-02-28 18:49:56] [email]tony2001@php.net[/email]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
[url]http://www.php.net/manual/[/url] and the instructions on how to report
a bug at [url]http://bugs.php.net/how-to-report.php[/url]
[url]http://www.php.net/manual/en/language.operators.php[/url]
------------------------------------------------------------------------
[2007-02-28 18:36:03] milman at gmx dot de
Description:
------------
$a = 1 + (1) ? 2 : 5 ;
should be the same as
$a = 1 + ((1) ? 2 : 5);
as
$a = 3 ;
Reproduce code:
---------------
<?php
echo "<body><xmp>\n" ;
$a = 1 + (1) ? 2 : 5 ;
echo "wrong: $a\n" ;
$a = 1 + ((1) ? 2 : 5);
echo "right: $a\n" ;
echo "</xmp></body>\n" ;
?>
Expected result:
----------------
wrong: 3
right: 3
Actual result:
--------------
wrong: 2
right: 3
------------------------------------------------------------------------
--
Edit this bug report at [url]http://bugs.php.net/?id=40669&edit=1[/url]
milman at gmx dot de Guest



Reply With Quote

