What are all the valid file extensions for PHP code?

Zig Shanklin asked
php file-extension
via

So far I’ve found the following file extensions are used for files that can contain PHP code.

.php
.php3
.php4
.php5
.php7
.phtml

.phar - PHAR Library
.phpt - PHP Test file
.phps - PHP source

What other file extensions are used to indicate that a file has PHP code? Are there other special purpose file extensions like .phar, .phpt or .phps?


Answer
via

Here are all of the ones I’ve seen over the past 15 years or so. Looks like you got nearly all of them, but I’m adding two or three other rarities.

.php
.php3
.php4
.php5
.php7
.phtml

.inc     - Used many years ago for includes.

.phar    - PHAR Library
.webphar - I've seen it done.
.web-phar
.phpt    - PHP Test file
.phps    - PHP source
.x-php   - Flag as PHP for an editor, but avoid parsing on server (rare).
    This is similar to .phps or a backup file.

.php~    - A backup, applies to all of the above.
Share This
Posted in: