php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #26273 conditional concatenator
Submitted: 2003-11-16 10:04 UTC Modified: 2003-11-17 21:03 UTC
From: tagg_maiwald at yahoo dot com Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 4.3.4 OS: Windows 98
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: tagg_maiwald at yahoo dot com
New email:
PHP Version: OS:

 

 [2003-11-16 10:04 UTC] tagg_maiwald at yahoo dot com
Description:
------------
A conditional concatenator would evaluate a boolean test, then concatenate a value onto the left operand. This operator would simplify scripts by eliminating a kludge. The motive behind this request is to readily construct SQL queries via PHP which can be easily reread and understood with minimal confusion by a follow-on person maintaining the script(s).

Reproduce code:
---------------
// kludge
$sz_string = 'foo';
if ($bool_test) { $sz_string .= 'bar'; }
else { $sz_string .= 'baz'; }
echo $sz_string

// conditional concatenator
$sz_string = 'foo';
$sz_string .? ($bool_test) 'bar' : 'baz';
echo $sz_string

Expected result:
----------------
foobar

Actual result:
--------------
foobar

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-11-17 16:50 UTC] jay@php.net
How is this any different from the already-implemented 
ternary operator? 
 
$sz_string .= ($bool_test) ? 'bar' : 'baz'; 
 
J 
 [2003-11-17 21:03 UTC] tagg_maiwald at yahoo dot com
Sorry. Need more sleep.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 17 13:01:27 2024 UTC