Why convert PHP to PHPS?
The only reason to use .phps is to let visitors read PHP source code in a browser with colour-coded syntax without the server executing it, which is useful for code tutorials or public demos where the source itself is what you want to show.
How to convert PHP to PHPS
Apache web server FREE
Rename the .php file to .phps, add AddType application/x-httpd-php-source .phps to your Apache config or .htaccess, and restart Apache.
XAMPP FREE
Install XAMPP, rename the .php file to .phps, add the AddType directive to XAMPP's Apache config, restart Apache from the XAMPP control panel, and browse to the file to verify the syntax highlighting.
About these formats
A PHP file is plain-text server-side source code written in PHP, the language behind WordPress and most content management systems. To read or edit it, open it in a text editor such as VS…
Open .PHP details →A .PHPS file is associated with PHP Script Source Code, a developer file.
Open .PHPS details →Quality & what to watch
- The
.phpand.phpsfiles are byte-for-byte identical; only the extension changes, which tells Apache which handler to invoke. - The
.phpssource handler is an Apache feature - Nginx has no built-in equivalent. - Never expose files containing database passwords or API keys as
.phps; any visitor who browses to the URL can read the full source.
Frequently asked questions
Do I need a special converter to change .php to .phps?
Does .phps work on shared hosting?
.phps handler and do not permit the required AddType directive in .htaccess.Can I test .phps locally?
.phps files on your local machine.