.PHP file extension
To open .PHP files on Windows, right-click the .php file → Open with → Visual Studio Code (or another code editor) to view/edit the source.
To open a .php file, use a code editor such as Visual Studio Code to view and edit the PHP source. If you expected a web page, upload it to a server configured to execute PHP (commonly via PHP-FPM or an Apache PHP handler) and access it through a browser.
Last updated: June 12, 2026
Open on your device
Choose your operating system for a dedicated step-by-step opening guide.
How to open .PHP files
Use these platform-specific instructions to open .PHP files safely.
Windows
- Right-click the .php file → Open with → Visual Studio Code (or another code editor) to view/edit the source.
- If you need it to execute as a web page, place it on a web server that’s configured to run PHP (for example, using PHP-FPM or an Apache PHP handler), then open the corresponding URL in a browser.
Mac
- Open the .php file in a code editor (for example, Visual Studio Code) to view/edit the PHP source.
- To see the generated web output, run it through a configured web server with PHP support (commonly via PHP-FPM) and open it in a browser via the server URL.
Linux
- Open the .php file in a code editor such as Visual Studio Code to view/edit the source code.
- To execute it as a web script, configure your web server to pass .php requests to PHP (commonly via PHP-FPM) and access it via http:// or https://.
iOS
- .php files are typically edited and executed in a server environment; for reliable viewing/editing, transfer the file to a desktop OS and open it in a code editor like Visual Studio Code.
Android
- .php files are typically edited and executed in a server environment; for reliable viewing/editing, transfer the file to a desktop OS and open it in a code editor like Visual Studio Code.
Security notes
- .php files can contain executable server-side code. Never deploy a .php file from an untrusted source on a server, because it may execute actions with your server’s permissions.
- If a server is misconfigured to serve .php as plain text, the source code (including passwords, API keys, or database credentials embedded in scripts) can be exposed to visitors.
- Avoid treating .php as a “document” to open in a browser from local disk expecting safe output; the PHP code is not executed locally by the browser and you may misinterpret what it does when run on a server.
- Be cautious with file upload features on websites: allowing users to upload .php (or upload files into executable directories) can enable remote code execution if the server executes uploaded scripts.
Before you run downloaded code
These files usually need a runtime (Python, Node, Java, …). They are not classic “file viruses,” but untrusted code can still do serious harm if you execute it. Prefer official packages, verify publishers, and scan archives or sketchy downloads when you are unsure.
Avast offers free and premium antivirus software that protects against viruses, malware, ransomware, and phishing. Scan files before opening them to ensure safety.
NortonNorton 360 delivers comprehensive antivirus protection, VPN, and identity theft monitoring. Scan files for threats before opening to keep your device secure.
We may earn a commission when you use affiliate links. This supports our free file extension guides.
Can't open this file?
These are the most common causes and fixes when .PHP files fail to open.
Common reasons
- Browser shows PHP source code instead of a web page
- Double-clicking a .php file doesn’t “run” it
- Web server returns an unexpected content type for .php
Fix steps
- Verify the site is hosted on a server configured to execute PHP (for example using PHP-FPM) rather than a static file host.
- Check your web server configuration to ensure .php requests are handled by PHP (for Apache, confirm the PHP handler configuration).
OS-specific troubleshooting
What is a .PHP file?
A .php file is plain-text source code written for the PHP server-side scripting language. In typical web setups, the server executes the PHP code and returns the generated output (often HTML) to the client, rather than sending the raw .php source to the browser. On many systems, file associations and web servers may map .php to a PHP-related MIME type for handling.
Background
PHP is a widely used server-side scripting language designed for web development. In practice, a .php file usually contains a mixture of PHP code and output templates that produce HTML or other response formats when executed on a server.
How a .php file behaves depends on context. In a code editor, it’s just text you can read and modify. In a web server environment, the server is configured so that requests for .php are handled by a PHP runtime (for example, PHP-FPM) and the result is returned to the browser.
Web server integration is commonly done either via FastCGI (PHP-FPM is the process manager used for this model) or via server-specific handlers. Configuration details vary by server, but the goal is the same: execute PHP scripts securely and efficiently when a .php resource is requested.
Common MIME types: application/x-httpd-php
Further reading
Authoritative resources for more details on the .PHP format.
Common .PHP issues
Browser shows PHP source code instead of a web page
This usually means the server is not executing PHP for .php files and is serving them as plain text (a misconfiguration that can also leak secrets in the code).
- Verify the site is hosted on a server configured to execute PHP (for example using PHP-FPM) rather than a static file host.
- Check your web server configuration to ensure .php requests are handled by PHP (for Apache, confirm the PHP handler configuration).
Double-clicking a .php file doesn’t “run” it
.php is source code intended to be executed by a PHP runtime, typically through a web server request; opening it directly usually just shows the text in an editor.
- Open the file in a code editor (such as Visual Studio Code) to inspect or edit it.
- If you need to see its output, run it on a PHP-enabled web server (commonly with PHP-FPM) and view it through a browser.
Web server returns an unexpected content type for .php
Servers may label PHP-related responses with non-standard or configuration-dependent MIME types (commonly seen as application/x-httpd-php), which can confuse tooling or downloads.
- If you control the server, review how it maps .php to handlers and content types; ensure PHP is executed and the response is sent with an appropriate type for the generated output (often text/html for HTML pages).
- If you do not control the server, treat the .php file as source code and open it in an editor rather than relying on browser rendering.
FAQ
Is a .php file a web page?
It’s usually the server-side source code used to generate a web page or API response. The browser typically receives the output produced by running the script, not the .php source itself.
What program should I use to open a .php file?
Use a code editor to view and edit it. Visual Studio Code has documented PHP language support for working with .php files.
What MIME type is associated with .php?
A commonly used (but non-standard) MIME type seen for PHP is application/x-httpd-php. MIME handling can vary by server configuration, and the correct response type often depends on what the script outputs (for example, HTML).
How do .php files run on a server?
Web servers are configured to route .php requests to a PHP runtime. A common approach is using PHP-FPM (FastCGI Process Manager) so the server can execute the script and return the generated response.
Similar file extensions
Compare related formats in the same category to find the right tool faster.