Here is what I have so far
file_put_contents('./'. $dir .'/'. file .'.php','<?php include "../head.php"; echo $head; ?>' . $body);
I also tried
file_put_contents('./'. $dir .'/'. file .'.php','<?php include "../head.php"; ?>' . $body);
and then echo $head;
in the /head.php
I want a head.php that is called by each of the generated files. There for I need to insert the php code <?php include "../head.php"; ?>
on top of the files.
with the given code <?php include "../head.php"; ?>
it shows  on top.
head.php
echo '<html>...';
echo $_SERVER['REQUEST_URI'];
...
The issue is, it shows . I don't think this is a dupe.