You can use PHP within other file types by defining a new Handler to the web server. For example to send all files that end in '.mytype' to the PHP engine add the following line to your .htaccess file.
AddHandler application/php mytype
You can specify multiple names on the same line by putting a space between them, for example:
AddHandler application/php mytype1 mytype2 mytype3
would send all files ending in '.mytype1', '.mytype2' or '.mytype3' to the PHP engine. You can now insert valid PHP code and the file will be processed by PHP.