#24503 [NEW]: writing newlines and multiline comments produces strange results

From: Date: Fri, 04 Jul 2003 22:52:02 +0000
Subject: #24503 [NEW]: writing newlines and multiline comments produces strange results
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-43285@lists.php.net to get a copy of this message
From: troublegum at woltlab dot de Operating system: Windows 2000 Professional PHP version: 5CVS-2003-07-04 (dev) PHP Bug Type: Filesystem function related Bug description: writing newlines and multiline comments produces strange results Description: ------------ OS: Windows 2000 Professional Server: Apache 1.3.27 PHP: Version 5.0.0b2-dev (cvs snapshot 07-04-2003) as apache module I wanted to create .php files dynamically. I tested the following test-script: Reproduce code: --------------- <?php $variables = array(1,2,3,4,5,6); $comments['comment1'] = "test1"; $comments['comment2'] = "test2"; $comments['comment3'] = "test3"; $fp = fopen("./file.php", "w"); //fwrite($fp, "<?php\n/*\ncomment1: ".$comments['comment1']."\ncomment2: ".$comments['comment2']."\ncomment3: ".$comments['comment3']."\n*/\n\n"); fwrite($fp, "<?php /* comment1: ".$comments['comment1']." comment2: ".$comments['comment2']." comment3: ".$comments['comment3']." */ "); // write variables to file fwrite($fp, "\n"); foreach($variables as $key=>$val) { fwrite($fp, "\$var_".$key." = \"".addcslashes($val,"$\"\\")."\";\n"); } fwrite($fp, "\n?>"); // close file and show results fclose($fp); echo "file written<hr />\n"; show_source("./file.php"); ?> Expected result: ---------------- The expected content of the file "./file.php" should be the following: <?php /* comment1: test1 comment2: test2 comment3: test3 */ $var_0 = "1"; $var_1 = "2"; $var_2 = "3"; $var_3 = "4"; $var_4 = "5"; $var_5 = "6"; ?> Actual result: -------------- Instead, the content which is written to "./file.php" is the following: <?php /* comment1: test1 comment2: test2 comment3: test3 * $var_0 = "1"; $var_1 = "2"; $var_2 = "3"; $var_3 = "4"; $var_4 = "5"; $var_5 = "6"; ?> So it is not surprising that show_source for this file results in Warning: Unterminated comment starting line 2 in c:\dev\htdocs\php5\fw.php on line 21 -- Edit bug report at http://bugs.php.net/?id=24503&edit=1 -- Try a CVS snapshot: http://bugs.php.net/fix.php?id=24503&r=trysnapshot Fixed in CVS: http://bugs.php.net/fix.php?id=24503&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=24503&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=24503&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=24503&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=24503&r=support Expected behavior: http://bugs.php.net/fix.php?id=24503&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=24503&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=24503&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=24503&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=24503&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=24503&r=dst IIS Stability: http://bugs.php.net/fix.php?id=24503&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=24503&r=gnused

« previous php.bugs (#43285) next »