PHP Apache Handler MIME Type
application/x-httpd-php means, how it relates to .php source files and Apache handlers, and how Poly supports it. MIME type details for application/x-httpd-php
In active use| MIME type | application/x-httpd-php |
|---|---|
| Extensions | .php |
| First standardized | Not standardized |
| Created by | Unknown |
| Browser support | Chrome, Edge, Firefox, Opera, Safari |
| Example applications | Visual Studio Code, PhpStorm, PHP CLI |
| Poly support | Yes. Poly recognizes `.php` files and the `application/x-httpd-php` label, so PHP source can be stored, synced, shared, and found by filename. |
| Indexed by Poly | Partial. PHP files are searchable by filename, but Poly does not currently index their source content. |
| Preview in Poly | No. PHP files labeled `application/x-httpd-php` do not currently open in a source preview; download them to inspect in a code editor. |
| Poly agent | No. The Poly agent does not currently read PHP source labeled `application/x-httpd-php`; provide a readable text copy when analysis is needed. |
What does application/x-httpd-php mean?
application/x-httpd-php is a long-standing Apache handler name used to tell the web server that a matching file should be processed by PHP. The PHP manual demonstrates it with a FilesMatch rule for .php files.1 Despite its MIME-shaped spelling, it is not a registered Internet media type. It does not appear in IANA's application media type registry.2
That distinction matters. Apache defines a handler as the action performed when a file is requested, separate from the file's content type. Its current documentation even recommends handler names without slashes so they do not occupy media-type syntax.3 application/x-httpd-php predates that cleaner convention and remains in deployed configuration.
application/x-httpd-php as a server instruction, not as the type a browser should receive for the generated page. PHP may produce HTML, JSON, an image, a download, or another response. The response should carry the media type of that output.How are PHP files identified?
The usual filename extension is .php. A PHP-aware Apache configuration can associate other extensions with the same handler, but the mapping is controlled by the server. The PHP manual shows both a narrow .php rule and a broader example covering historical names such as .php3, .php4, .php5, and .phtml.1
PHP source has no dependable magic number. A file can begin with <?php, but PHP can also be embedded after ordinary HTML or other text. The PHP parser uses <?php and ?> to enter and leave PHP mode, and content outside those tags can pass through as output.4 A fixed signature would therefore miss valid files.
Desktop file classifiers often use a different unregistered label, application/x-php. The freedesktop.org shared MIME database describes that type as a text-based PHP script, associates it with several PHP extensions, and uses a nearby <?php tag only as supporting detection evidence.5 Neither label is an IANA standard.
.php for ordinary source files unless a specific deployment requires another suffix. Do not assume that changing a filename changes which interpreter, PHP version, or server configuration will run it.Where did the label come from?
Rasmus Lerdorf created the first PHP tools in 1994 and released their source publicly in June 1995. PHP then evolved from CGI utilities into a programming language, with PHP 3 released by the PHP Development Team in 1998.6
The application/x-httpd-php spelling grew out of the Apache module integration around that ecosystem. There is no IANA registration that assigns it an author, creation date, parameters, or official extensions. The x- prefix reflects an older custom for private or experimental names. RFC 6648 later discouraged creating new X- names because widely deployed private conventions tend to become permanent and create interoperability problems.7
The label is still meaningful when reading an existing Apache configuration or metadata record. It should not, however, be treated as a portable description of a PHP source file across every web server, desktop, and API.
How to open a .php file
A PHP file is source text, so any text editor can open it. A language-aware editor is more useful for navigation, formatting, diagnostics, and completion.
- Visual Studio Code includes PHP syntax highlighting, bracket matching, completion, snippets, and integration with the PHP linter.8
- PhpStorm recognizes file types by filename patterns and provides PHP-focused editing and project tools.9
- The PHP command-line interface can execute a trusted file with
php my_script.phporphp -f my_script.php. The CLI does not require the file to end in.php.10
Opening source and executing it are different actions. Use an editor when you only need to inspect or change a file. Run it only in an environment where its dependencies, configuration, permissions, and inputs are understood.
What do browsers do with application/x-httpd-php?
Chrome, Edge, Firefox, Opera, and Safari can display the result of a PHP-backed URL, but they do not execute PHP. The web server runs PHP and sends the generated response to the browser. The PHP tutorial demonstrates a .php request producing an ordinary HTML document.11
If a server sends raw PHP source instead, browser behavior depends on headers and local settings. It may show the text or download the file. That is normally a server configuration failure, not useful PHP support. PHP's installation FAQ specifically identifies visible source as evidence that the server did not pass the script to PHP for interpretation.12
The output media type should match the generated content. An HTML page normally uses text/html; a JSON endpoint normally uses application/json. Sending application/x-httpd-php to the browser confuses an internal handler name with the representation delivered over HTTP.
Support in Poly
Poly recognizes the application/x-httpd-php label and the .php extension. You can store, sync, share, version, and find these files by name. Poly does not currently provide an in-app PHP source preview, source-content indexing, or direct agent reading for this label.
Download the file and open it in a trusted code editor when you need to inspect its contents. If you want the Poly agent to analyze a script, provide a separate readable text copy and include any related configuration or source files needed to understand it. Poly does not execute PHP code.
Is application/x-httpd-php the same as application/x-php?
No, although both are commonly associated with PHP.
| Label | Typical role | Registered by IANA? | What it communicates |
|---|---|---|---|
application/x-httpd-php | Apache handler name | No | Process a matching request with PHP |
application/x-php | Desktop file classification | No | Treat the file as PHP source text |
text/plain | Generic text media type | Yes | Display or transfer text without a PHP-specific meaning |
text/html | Web response media type | Yes | Interpret the response as HTML |
These labels are metadata, not conversions. Renaming index.php to index.txt does not remove executable PHP statements, and changing an HTTP header does not run the source. Server configuration determines whether a requested file is executed.
Converting or publishing PHP source
PHP source usually does not need conversion. Choose an operation based on the actual goal:
- Share source for review. Keep the
.phpfile, or make a clearly labeled plain-text copy when a system cannot read PHP-specific metadata. - Publish generated HTML. Run trusted code in a controlled environment, capture its output, and save that output as
.html. This creates a snapshot and does not preserve server-side behavior. - Show code on a website. Escape the source as text and serve the page as HTML. Do not place a live script in a public web root merely to display it.
- Move to another language. Rewrite and test the behavior. A filename or MIME-type change cannot translate program logic.
Security and privacy considerations
PHP source is executable code. It can access files, databases, credentials, networks, and other services available to its process. Inspect unfamiliar code and dependencies before running them, and use an isolated environment with the minimum necessary permissions.
Extension matching also deserves care. PHP's Apache installation guide recommends an end-anchored match so a filename such as exploit.php.jpg is not accidentally executed as PHP.1 Treat the MIME label and extension as hints, not proof that a file is safe or that its contents match its name.
Footnotes
- PHP Project. Apache 2.x on Unix Systems. Shows
SetHandler application/x-httpd-php, extension matching, and the security reason for anchoring the rule. ↩ ↩2 ↩3 - Internet Assigned Numbers Authority. Media Types Registry. The application registry does not include
x-httpd-php. ↩ - Apache Software Foundation. Apache's Handler Use. Defines handlers separately from content types and explains the modern naming convention. ↩
- PHP Project. PHP Tags. ↩
- freedesktop.org shared-mime-info, mirrored by Debian Sources.
application/x-phpDefinition. Lists text inheritance, detection evidence, and filename patterns. ↩ - PHP Project. History of PHP. ↩
- Saint-Andre, P., Crocker, D., and M. Nottingham. RFC 6648: Deprecating the
X-Prefix and Similar Constructs in Application Protocols. Internet Engineering Task Force, June 2012. ↩ - Microsoft. PHP in Visual Studio Code. ↩
- JetBrains. File Type Associations in PhpStorm. ↩
- PHP Project. Executing PHP Files from the Command Line. ↩
- PHP Project. Your First PHP-Enabled Page. ↩
- PHP Project. Installation FAQ. ↩