RE: [PHP] using fwrite to create PHP files

From: Date: Fri, 05 Sep 2003 12:06:13 +0000
Subject: RE: [PHP] using fwrite to create PHP files
Groups: php.general 
Request: Send a blank email to php-general+get-161748@lists.php.net to get a copy of this message
[snip] 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: [/snip] Vince I did this <?php /* ** Write PHP with PHP ** 2003-09-05 */ $newphp = fopen("/usr/server/test/new_php.php", "w"); fputs($newphp, "<?php\n"); fputs($newphp, "This is a PHP by PHP writing test.\n"); fputs($newphp, "?>\n"); fclose($newphp); ?> And it worked fine. fputs() places the string in the file properly. I also noticed at the end of your script.... write($new_file, $new_file_content); Since I saw no write() function in your script I would have to assume that you are calling an undefined function, which is probably where your errors are coming from. Try changing the line to fputs($new_file, $new_file_content); And you should have much luck. Have a pleasant, productive and meaningful day.

« previous php.general (#161748) next »