#34409 [Opn->Fbk]: concatenating a "\n" to a single character string produces incorrect output

From: Date: Thu, 08 Sep 2005 05:35:41 +0000
Subject: #34409 [Opn->Fbk]: concatenating a "\n" to a single character string produces incorrect output
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-84677@lists.php.net to get a copy of this message
ID: 34409 Updated by: sniper@php.net Reported By: dskiles at docfinity dot com -Status: Open +Status: Feedback Bug Type: Strings related Operating System: Windows XP sp2 PHP Version: 5.0.5 New Comment: In your original script, if you change the line with echo to this: $a = "$val\n"; var_dump($a); What is the output? Previous Comments: ------------------------------------------------------------------------ [2005-09-07 17:43:42] dskiles at docfinity dot com PHP 5.1.0-dev (cli) (built: Sep 7 2005 12:38:38) Copyright (c) 1997-2005 The PHP Group Zend Engine v2.1.0-dev, Copyright (c) 1998-2005 Zend Technologies With PHP_EOL: a b c d ------------------------------------------------------------------------ [2005-09-07 17:38:36] scottmacvicar at ntlworld dot com 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); ------------------------------------------------------------------------ [2005-09-07 17:29:14] dskiles at docfinity dot com I get this result back: string(2) "a " string(3) "a " Does PHP not offer a universal "\n", like Python or Java? ------------------------------------------------------------------------ [2005-09-07 17:24:50] tony2001@php.net Try this code: <?php var_dump("a\n"); var_dump("a\r\n"); ?> ------------------------------------------------------------------------ [2005-09-07 17:21:04] dskiles at docfinity dot com Scott, I noticed that you were using a UNIX shell, so I fired up Cygwin and tried the same thing on my box. Cygwin: a b c d Windows Shell: ???? ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/34409 -- Edit this bug report at http://bugs.php.net/?id=34409&edit=1

« previous php.bugs (#84677) next »