0

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.

  • you want to add a line to the top of a file? –  Jul 25 '19 at 21:05
  • that's right, or append the bod.php part, either way. – B. Richardson Jul 25 '19 at 21:13
  • Possible duplicate of [Need to write at beginning of file with PHP](https://stackoverflow.com/questions/1760525/need-to-write-at-beginning-of-file-with-php) –  Jul 25 '19 at 21:14
  • it is not that i can not write to a file. it is that the code `` does not appear in the file. how would prepending make a difference? – B. Richardson Jul 25 '19 at 21:23
  • "not that i can not write to a file" "it is that the code .. does not appear in the file" sorry they seem to contradict, I'm totally lost. –  Jul 25 '19 at 21:36

0 Answers0