What is a .php file?
A .php file is a PHP script. Its registered MIME type is application/x-php, which places it in the application or document family of formats.
Technically it is a specialised form of text/plain (the .asc format), so tools that understand that format can often read at least part of it.
PHP is a text-based format: the contents are readable characters, so any text editor can open it, and it compresses well.
The same format is also saved with the extensions .php3, .php4, .php5, .phps.
PHP file format details
| Extension | .php |
|---|---|
| Format | PHP script |
| MIME type | application/x-httpd-php, application/x-php |
| Category | Application or document |
| Text or binary | Text |
| Based on | text/plain |
| File signature | None fixed |
| Registered with IANA | No |
| Other extensions | .php3, .php4, .php5, .phps |
How to open PHP files
| Windows | PHP files are plain text, so Notepad opens them: right-click the file, choose Open with, then Notepad. Notepad++ and VS Code are free and show long files more comfortably. |
|---|---|
| Mac | TextEdit opens plain text files. For code or data files, a free editor such as BBEdit or VS Code keeps the formatting intact. |
| iPhone and iPad | Save the file to the Files app and tap it; iOS previews most plain text. Or drop it on the viewer above, which shows the text right in the browser. |
| Android | Most file manager apps open plain text files in a built-in viewer. The viewer above also works in Chrome. |
Can you convert a .php file?
TapToConvert does not convert PHP files. The usual route is to open the file in the program that made it and use its Export or Save as option.
PHP file FAQ
What is a .php file?
A .php file is a PHP script, with the MIME type application/x-php.
How do I open a .php file?
With any text editor, such as Notepad on Windows or TextEdit on a Mac, or with the viewer on this page.
Is a .php file safe to open?
Treat it with care: PHP files can contain code that runs on your computer. Only open ones from sources you trust. Viewing one with the viewer on this page is safe, because it only reads the bytes and never runs them.
What is the MIME type of .php?
application/x-php, and it is also seen as application/x-php. Web servers send this type so browsers know how to handle the file.
Is PHP a text or binary format?
Text. Its contents are readable characters.
File type facts come from the IANA media type registry, the mime-db project and the freedesktop.org shared MIME database.