From:             
Operating system: Irrelevant
PHP version:      Irrelevant
Package:          Scripting Engine problem
Bug Type:         Feature/Change Request
Bug description:Shortcut "ternary" companion operator

Description:
------------
The expression $a ? $b : $c can be shortened to $a ?: $c if $b==$c.



In this the "?:" operator behaves much like the "||" operator in, say, Perl
or JavaScript, or the "or" operator of Python: "$a if it looks true, $c
otherwise".



But those three languages also have "&&" (or "and") operators which mean
"$a if it looks false, $c otherwise".



PHP currently lacks such an operator: where Python can have "a and c", PHP
still needs "$a ? $c : $a", including the potential double evaluation or
intermediate variable needed if "$a" is anything more complex.



So the Feature Request is another operator, perhaps ":?", which behaves as
described in the third paragraph above: "$a :? $c" would be an abbreviation
for and equivalent to "$a ? $c : $a". It's possible to come up with a
tortured bit of algebra to justify the ":?" symbol, but aesthetic symmetry
ought to be enough of an excuse both for the symbol and more importantly
the operator it identifies.


-- 
Edit bug report at http://bugs.php.net/bug.php?id=54106&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=54106&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=54106&r=trysnapshot53
Try a snapshot (trunk):              
http://bugs.php.net/fix.php?id=54106&r=trysnapshottrunk
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=54106&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=54106&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=54106&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=54106&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=54106&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=54106&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=54106&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=54106&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=54106&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=54106&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=54106&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=54106&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=54106&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=54106&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=54106&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=54106&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=54106&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=54106&r=mysqlcfg

Reply via email to