строка изменения в файле php

например, у меня есть этот файл php:

{ $data= 'anydata'; $age = '33'; $site ='mysite'; $name = 'anyname' } 

Вопрос: Как я могу изменить строки с помощью php?

fgets, прочитайте одну строку, со страницы руководства здесь

fwrite, с страницы руководства здесь

unlink, от страницы руководства здесь

переименовать, с страницы руководства здесь

chmod, с страницы руководства здесь

 1. Open file1 (in file), file2 (outfile) 2. use fgets reading single lines (the next line) from file1 3. need to modify that string? do so. 4. use fwrite to write string to file2 (just that line) 5. loop back to 2 when not end-of-file (eof) of file1 6. close file1 and file2 7. unlink (delete) file1 8. rename file2 to file1 name 9. chmod accordingly