ID:               24503
 Updated by:       [EMAIL PROTECTED]
 Reported By:      troublegum at woltlab dot de
-Status:           Open
+Status:           Closed
 Bug Type:         Filesystem function related
 Operating System: Windows 2000 Professional
 PHP Version:      5CVS-2003-07-04 (dev)
 New Comment:

Not really a bug in PHP, but a text-mode translation issue.
Yes, that comment was recently added to the manual pages.



Previous Comments:
------------------------------------------------------------------------

[2003-07-05 06:11:49] troublegum at woltlab dot de

Well, this works for me now. Thank you.
I found this in the fopen manual entry. It was recently added, wasn't
it?
> It is strongly recommended that you always use the 'b'
> flag when opening files with fopen().

------------------------------------------------------------------------

[2003-07-05 03:27:41] [EMAIL PROTECTED]

try fopen("file.php", "wb") instead.

------------------------------------------------------------------------

[2003-07-04 17:52:02] troublegum at woltlab dot de

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 this bug report at http://bugs.php.net/?id=24503&edit=1

Reply via email to