|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-09-27 10:07 UTC] derick@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Wed Feb 11 10:00:02 2026 UTC |
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)