I’m fairly new to PHP, so I’m sorry if this is a dumb question.
I’m trying to create something to write a PHP file to another file in another directory. The idea being that all the generated directories have to include a file which is run via cron, however I can’t simply just copy the file because part of the file is dependant on a variable that exists when the directory gets created, but isn’t always going to be there.
It would be the same scenario as writing the following to a file (obviously this is an example):
<?php
$test = mysql_query("SELECT * FROM table WHEN memberID='$groupID'");
?>
How would I get the variable $groupID from the file carrying out the fopen('','w') function which is writing the new PHP file? Can anyone give an example of writing the above to a file?
Thanks in advance!
EDIT: I’ve accepted the answer to the original question, however the answer from @MichaelBerkowski is an efficient alternative to consider.
Not sure if I correctly understood what you want to do, but in case I did:
This will write the content you provided (the PHP file) into the file “yournewfile.php”