From:             kossarev at hytti dot uku dot fi
Operating system: Windows 2000
PHP version:      4.3.9RC3
PHP Bug Type:     Zend Engine 2 problem
Bug description:  string concatenation with . terminates while using ternary ? operator

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 bug report at http://bugs.php.net/?id=30238&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=30238&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=30238&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=30238&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=30238&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=30238&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=30238&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=30238&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=30238&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=30238&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=30238&r=notwrong
Not enough info:             http://bugs.php.net/fix.php?id=30238&r=notenoughinfo
Submitted twice:             http://bugs.php.net/fix.php?id=30238&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=30238&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=30238&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=30238&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=30238&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=30238&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=30238&r=float
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=30238&r=mysqlcfg

Reply via email to