0

I am generating some PHP source code files using PHP only :)

And I want to know if I have to write some line of text before closing brackets, how can I do that using PHP file functions.

e.g. below is my target file code. filename : project.php

Class project{
   public function get_project($id){
   ..... some code here
   }

   public function add_project(){
   ..... some code here
   }

   <--- add code here
}

I have a line of code which I want to add to the position pointed in the example. I can use file_put_content() method but it has option to Append the code on the end of the file like below

file_put_contents('project.php', 'Hello World', FILE_APPEND);

but it will not write to specific position. So how can I do that?

aslamdoctor
  • 3,753
  • 11
  • 53
  • 95

0 Answers0