So in my script I copy a PHP file used as a model and/or template file. But i can not figure out how to find the data that needs to be edited, and editing it. I don't want to truncate the whole file just need to edit a line of text in the file and save it. Below is what I have so far.
$file = '../postback/postback.php';
$pbac = '../postback/'.md5($affn).'.php';
copy($file, $pbac);
$files = file_get_contents($pbac);
// Stick the new IP just before the closing </files>
$new_files = str_replace('//ADD NAME HERE//', "//ADD NAME HERE//
\$name ='".$affn."';", $files);
// And write the new string back to the file
file_put_contents($pbac, $new_files);
$pback = '/postback/'.md5($affn).'.php';
As you can see I have the code to do it. But it is not working. I don't know what i am doing wrong. perhaps someone else looking at it can point out the problem.
The file is copied. There are no errors displaying or listing in my error log. There are no edits being made though. //ADD NAME HERE// Is on a line by itself.