this is a sample of what I do when I need to write a php file $stringtowrite = "<?PHP\n// Bulletin Board forum\n$"."ForumId=".$tabletofind.";\n";
$stringtowrite .= "$"."ForumActive='1';\n$"."ForumName='".$sportname."';\n"; $stringtowrite .= "$"."ForumDescription='".$sportname." forum';\n"; $stringtowrite .= "$"."ForumConfigSuffix='';\n"; $stringtowrite .= "$"."ForumFolder='0';\n"; $stringtowrite .= "$"."ForumParent='0';\n"; $stringtowrite .= "$"."ForumLang='lang/english.php';\n"; --- and so on until finally $fd=fopen($final_destination,"w") or die ("file won't open"); /*if ($fd===false) { echo "file create failed"; exit(); //return; } */ fwrite($fd,$stringtowrite); fclose($fd); <-- snip --> > Vince LaMonica wrote: > > > I wish to use fwrite() to create a small PHP file. So far, when I attempt > > to do this, php parses the contents of the file that fwrite needs to > > create. Eg, I have this: > > > > $new_id = mysql_insert_id(); > > // create brand new file > > $new_file = fopen("/var/www/html/$sitename/$submitted_url", "w"); > > $new_file_content = "\n" > > ." <?php \n" > > ." if ($_GET['preview'] == \"y\") { \n" > > You need to escape the dollar signs in your string. > > ." if (\$_GET['preview'] == \"y\") { \n" > > -- > ---John Holmes... <-- snip --> Chris Sherwood -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php