Here is what I'm trying to do. I want to use PHP's fwrite function in order to write PHP to another file, like so: $fh = fopen($src,'w')or die("Error"); $data = "<?php //Insert whatever code here ?>"; fwrite($fh,$data); fclose($fh); PHP: In otherwords, I would like to write a script using PHP to another PHP file. Anyone know how this would be possible?
Is there some reason that the code above doesn't work for you? Of course, it will tak ea little more to publish actual code that way, you need to get comfortable properly escaping string characters, too. But you've got the basics of it right there.
What's wrong with it. Should work fine unless I am missing something. Though setting a variable for the data is almost completely useless unless you are going to being doing other things to the text before you put it into the file.
every file has its own CHMOD permission, once the target file is CHMOD 666 then its editable, writable by you as the owner. if you have problems with CHMOD, try changing the file CHMOD from 666 to 777