|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-09-07 15:50 UTC] dskiles at docfinity dot com
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:
--------------
????
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 15:00:01 2025 UTC |
Try this code: <?php var_dump("a\n"); var_dump("a\r\n"); ?>Try this then, though i can't see why it woudl end up one character. Are you sure your using the latest CVS version? Check php -v echo("$val" . PHP_EOL);