Req #52148 [Opn->Bgs]: Modify ternary operator request
Edit report at http://bugs.php.net/bug.php?id=52148&edit=1
ID: 52148
Updated by: rasmus@php.net
Reported by: clouster at yandex dot ru
Summary: Modify ternary operator request
-Status: Open
+Status: Bogus
Type: Feature/Change Request
Package: *Programming Data Structures
Operating System: all
PHP Version: Irrelevant
New Comment:
The operator exists. Try your code like this in PHP 5.3:
echo $foo ?: "bar";
echo $bar ?: "bar";
Previous Comments:
------------------------------------------------------------------------
[2010-06-22 16:37:21] clouster at yandex dot ru
sorry for "stream of consciousness" and my bad english :)
Actually when i said "modify ternary operator" i mean to add new ternary
operator.
------------------------------------------------------------------------
[2010-06-22 16:35:23] clouster at yandex dot ru
Description:
------------
There is a need for another operator, which would reduce the code
dramatically.
Be sure there are situations when stupid testing for validity get load
of code,
so i suggest modify ternary operator ( expression ? true : false ) to
next
variant:
$foo = "hello";
$bar = "world";
$output = $foo ? $bar;
$output is "hello";
$foo = null (0, false, etc);
$bar = "world";
$output is "world";
Test script:
---------------
$foo = false;
$bar = "foo";
echo $foo ? "bar";
echo $bar ? "bar";
Expected result:
----------------
bar
foo
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=52148&edit=1
Thread (3 messages)