PHP runs as "httpd" on many servers. That means the PHP script only has the same access privileges as someone browsing your website. You can see why making a public file 0777 (writable + deletable by the outside public) would be bad.
Rather than try to edit the contents of the PHP from another PHP, have the PHP grab data from a database or external file outside your web directory.
Like:
/usr/elvis/includedata.txt
/usr/elvis/www/myphpscript.php
chmod /usr/elvis/includedata.txt 0777
in myphpscript.php, you can read from and write to includedata.txt without worrying about the public getting access to that file.