#30238 [Opn->Bgs]: string concatenation with . terminates while using ternary ? operator

From: Date: Mon, 27 Sep 2004 08:07:31 +0000
Subject: #30238 [Opn->Bgs]: string concatenation with . terminates while using ternary ? operator
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-66749@lists.php.net to get a copy of this message
ID: 30238 Updated by: derick@php.net Reported By: kossarev at hytti dot uku dot fi -Status: Open +Status: Bogus Bug Type: Zend Engine 2 problem Operating System: Windows 2000 PHP Version: 4.3.9RC3 New Comment: Sorry, but your problem does not imply a bug in PHP itself. For a list of more appropriate places to ask for help using PHP, please visit http://www.php.net/support.php as this bug system is not the appropriate forum for asking support questions. Thank you for your interest in PHP. No bug, this is related to operator precedence. Previous Comments: ------------------------------------------------------------------------ [2004-09-26 03:13:05] kossarev at hytti dot uku dot fi Description: ------------ Firstly, thank you for developing the great and powerful PHP language. And the bug: consider the following code.. (from next box) the first . operation terminates prematurely while using the ternary operator at the end of the statement. so i have to use a version commented out by /* */ Reproduce code: --------------- for ($i=2; $i<=$loop_count; $i++) { //bug is in the first statement: $query_string .= $dest_fields[$i-1][0]." = '".$init_array[$i]."'".($i<$loop_count)?(", "):(" ");*/ //so i have to use this version: /*$query_string .= $dest_fields[$i-1][0]." = '".$init_array[$i]."'"; $query_string .= ($i<$loop_count)?(", "):(" ");*/ } Expected result: ---------------- i expect concatenation operation to use values in $dest_fields and $init_array[, which contain simple string values (database columns and respective fields): user_id = '225', last_edit = '2004-09-26 04:08:40', language_id = '1', title = 'dfdfdsfdsa', province_id = '1', locality = 'Monako', selftype_id = '1', searchedtype_id = '1', purpose_id = '2', submenu_id = '0', messagetext = 'adsf öfdsölkfdasökfdök jöa' Actual result: -------------- using a 1-line statement version, i only get the result of ternary comparison in the resulting $query_string: , , , , , , , , , , , somehow values in $dest_table and $init_array[$] get skipped.. i suspect that presence of a ? ternary operator causes the string concatenation with . to exit prematurely. it however works when devided into two lines of code (commented out in the code example) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=30238&edit=1

« previous php.bugs (#66749) next »