You could use a PHP include file as follows:
1. Set up an include file, which contains the original code.
2. Load the contents of the include file into a textarea to make it amendable.
3. Write the amended code back to the include file.
4. Include the updated include file, and voila, the code has been permanently amended, but is still updatable.
Trouble is, executing code written into a textarea is very error prone, let alone a security risk! I would most strongly suggest you should not do this, but it can be done.