Embedded PHP can be stripped from the source of a file if you edit the file using the graphical mode ("Edit") instead of the source view ("Source"). When you add PHP script to the source view of a page for the first time wrap it in <cmignore> tags like this:
<cmignore><?php echo 'test'; ?></cmignore>
Formatting may still get messed up, but your code will remain intact. Code on multiple lines may be re-flowed so that it's all on one line, which means that comments within the PHP should use
/* this notation style */
/* of comments */
instead of
// this notation style
// which will break your PHP
// when these four lines are pushed
// into one line.