Not been here in a while (years 🙁 ), but I've finally realised that I need a forum dedicated to PHP rather than asking on general forums. Anyway...
I've encountered a problem in what is the staple piece of code in the system I'm developing. I'm trying to essentially copy PHP files from one server to another. Here's the code I've got at the moment:
$modulef = fopen($path."module.inc.php", 'r');
$module = '';
while($line = fread($modulef, 1024)){
$module .= $line;
}
$newfile = "/home/sites/modoerenuniverse.co.uk/public_html/new/modules/".$row['moduleDirectory'].".inc.php";
touch($newfile);
$fp = fopen($newfile, 'w');
flock($fp, LOCK_EX);
fwrite($fp, $module);
flock($fp, LOCK_UN);
fclose($fp);
Now I've tried both fread() and file_get_contents() and both functions have given me the same error - they process the file and read the output, instead of reading the source. My question is: how can I stop the file from being processed, and just read the underlying PHP code within the file? Or alternatively, is there some completely different way of copying the file itself?