#34409 [NEW]: concatenating a "\n" to a single character string produces incorrect output

From: Date: Wed, 07 Sep 2005 13:50:32 +0000
Subject: #34409 [NEW]: concatenating a "\n" to a single character string produces incorrect output
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-84626@lists.php.net to get a copy of this message
From: dskiles at docfinity dot com Operating system: Windows XP sp2 PHP version: 5.0.5 PHP Bug Type: Strings related Bug description: concatenating a "\n" to a single character string produces incorrect output Description: ------------ I've been running into a problem where a single character string will turn into a '?' character when I attempt to concatenate it or interpolate it with a single "\n" character. If I use a multi-character string or multiple "\n" characters I don't get '?' characters anymore. I'm running this from the console. Reproduce code: --------------- <?php class Environment { //todo: add persistance const ALLPAIRS = 0; const EXHAUSTIVE = 1; ///factors is a multidimenstional associative array. ///the key for the main array is the factor. The value of that key is a traditional array of values private $factors; ///FactorMaps are 1:1 concrete representations made out of the factors private $factorMaps; ///Mode states how FactorMaps are made from the factors ///Currently, allpairs and exhaustive are supported private $mode; public function __construct($mode=Environment::ALLPAIRS) { $this->factors = array(); $this->factorMaps = array(); $this->mode = $mode; } public function addFactorValues($factor, $values) { if (!isset($this->factors[$factor])) { $this->factors[$factor] = array(); } $this->factors[$factor] = array_merge($this->factors[$factor], $values); //todo: update the factormaps if any factors were added } public function getFactorValues($factor) { return $this->factors[$factor]; } } ?> ///////////////////////////////////////////// <?php require('../Environment.php'); $enviro = new Environment(); $enviro->addFactorValues('test', array('a', 'b', 'c', 'd')); foreach($enviro->getFactorValues('test') as $val) { echo("$val\n"); } ?> Expected result: ---------------- a b c d Actual result: -------------- ???? -- Edit bug report at http://bugs.php.net/?id=34409&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=34409&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=34409&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=34409&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=34409&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=34409&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=34409&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=34409&r=needscript Try newer version: http://bugs.php.net/fix.php?id=34409&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=34409&r=support Expected behavior: http://bugs.php.net/fix.php?id=34409&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=34409&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=34409&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=34409&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=34409&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=34409&r=dst IIS Stability: http://bugs.php.net/fix.php?id=34409&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=34409&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=34409&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=34409&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=34409&r=mysqlcfg

« previous php.bugs (#84626) next »