.PHP

PHP File

PHP Script / Hypertext Preprocessor Source File
Ask a question
QUICK ANSWER

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 Code or Notepad++. To run it and see its output, you need a web server with PHP - locally via XAMPP or PHP's built-in server - because PHP executes on the server, not in the browser.

Developer: The PHP Group (originally Rasmus Lerdorf) Category: Web Files Open standard MIME: application/x-httpd-php
OPENS ON Windows macOS Linux

On this page

19k+ extensions indexed
Last reviewed Aug 5, 2026

Not sure what your file is?

Drop any file into our identifier - we read just the first bytes to name the format.

Identify a file

What is the PHP file format?

A .php file is a plain-text document that contains source code written in PHP (Hypertext Preprocessor), a widely-used server-side scripting language. A .php file can contain PHP code mixed with HTML markup, text, and inline CSS or JavaScript.

PHP file applications

PHP files are used to generate HTML pages dynamically using the server's PHP engine. PHP files are also used to create web applications. Websites commonly utilize .php files to process online forms - for example, a contact data form - or as a means to access databases. WordPress, a well-known content management system, uses PHP scripts extensively, as do popular frameworks such as Laravel and Symfony.

Processing PHP files

PHP file code is processed by the PHP engine residing on the web server, which generates dynamic HTML output. This HTML content is then sent to the user's web browser and displayed as a web page. This process ensures that actual PHP code cannot be accessed by the user, even by viewing the page source. PHP code blocks begin with the <?php opening tag; the closing ?> tag is intentionally omitted at the end of pure script files to prevent unintended output before HTTP headers are sent.

Additional information

  • index.php is often the main website file loaded by the web browser when a directory is requested.
  • PHP can also be executed from the command line using php script.php.
  • Other file extensions that also carry PHP code include .phtml, .phps, .php3, .php4, .php5, and .php7.

Security & safety

RISK: MEDIUM

A .php file is a program that runs ON A SERVER, so a malicious PHP script (a "web shell" like c99/r57) uploaded to a site can let an attacker run commands, read the database, or take over the server - never deploy .php files from untrusted sources to a live site without reviewing them. Merely opening a .php in a text editor is safe (it's only text) and does NOT execute it. Two operational risks: (1) .php files often contain database passwords and API keys, so they must not be publicly downloadable; (2) running PHP on an outdated, end-of-life version (PHP 5/7) exposes known vulnerabilities - keep PHP updated to a supported 8.x branch.

Format details

in a nutshell
FULL NAMEPHP Script / Hypertext Preprocessor Source File
DEVELOPERThe PHP Group (originally Rasmus Lerdorf)since 1995 (PHP/FI by Rasmus Lerdorf); PHP 8.x is current
CATEGORYWeb Files
MIME TYPEapplication/x-httpd-php
TYPEPlain-text server-side script (PHP source code, often mixed with HTML)
STANDARDOpen · royalty-free

Programs that open PHP files

Windows4 apps
Notepad Open-source Open the .php to view or edit the source with highlighting (does not execute it).
Visual Studio Code Free Open the .php to read/edit with PHP syntax highlighting; add the PHP/Intelephense extension for autocompletion.
XAMPP (Apache + PHP + MySQL) Open-source Install XAMPP, put the .php in the htdocs folder, start Apache, then browse to http://localhost/file.php to RUN it.
PHP (built-in server) Open-source Install PHP, then in the file's folder run 'php -S localhost:8000' and open http://localhost:8000/file.php to execute it.
macOS3 apps
BBEdit Freemium Open the .php to edit with PHP syntax support (free mode covers editing).
Visual Studio Code Free Edit .php with the PHP extension. macOS may include a CLI 'php'; otherwise install via Homebrew ('brew install php').
MAMP Freemium Local Apache/Nginx + PHP + MySQL stack for Mac - drop the .php into the document root and run it via localhost.
Linux2 apps
Visual Studio Code Free Edit .php with highlighting and the PHP extension.
PHP CLI + Apache Open-source Install via the package manager (e.g. 'apt install php apache2'). Run a file with 'php file.php', or serve it via Apache/Nginx.

Technical details

deep spec
File typePlain-text server-side script, UTF-8 encoded
MIME typeapplication/x-httpd-php
File signature (magic bytes)None - plain text with no binary signature; files typically open with the <?php tag at byte offset 0
Opening tag<?php (standard block) or <?= (short echo tag for inline output)
Closing tag?> - optional; intentionally omitted at the end of pure PHP files to avoid accidental whitespace output before HTTP headers
Execution modelServer-side; the PHP engine on the web server interprets the file and delivers the resulting HTML to the client browser
PHP engineZend Engine - the core interpreter powering the official PHP runtime, with JIT compiler support
CLI executionphp script.php or php -f script.php
Variable syntaxAll variable names are prefixed with $ (e.g. $name, $count, $items)
Case sensitivityVariable names are case-sensitive; function and class names are not
Superglobals$_GET, $_POST, $_SESSION, $_COOKIE, $_SERVER - pre-defined arrays for HTTP request and session context
Major frameworks and CMSLaravel, Symfony, CodeIgniter (frameworks); WordPress, Drupal, Joomla (content management systems)
Database accessBuilt-in MySQLi and PDO extensions; supports MySQL, PostgreSQL, SQLite, and other databases
Runtime configurationphp.ini controls memory limits, error reporting, file upload sizes, and which extensions are loaded
Related extensions.phtml (PHP/HTML template mix), .phps (PHP source display), .php3 / .php4 / .php5 / .php7 (legacy versioned PHP scripts)
Released1995 (PHP/FI by Rasmus Lerdorf); PHP 8.x is current
Open standardYes · royalty-free
Specificationwww.php.net

PHP conversions

Community Q&A

asked by users
Ask a quick question
Get help from people who work with PHP files. Be specific - include your system and software version.
No account needed · answers usually within a day

No questions yet - be the first to ask about PHP files.

Frequently asked questions

How do I open a .php file?
To READ or edit the code, open it in a text editor like VS Code or Notepad++ (it's plain text). To SEE what it produces, you must run it on a web server with PHP - locally via XAMPP/MAMP or 'php -S localhost:8000' - because PHP executes server-side, not in the browser.
Why does my .php file show as plain text / code in the browser?
Because there's no PHP engine running it. Opening a .php from your hard drive in a browser doesn't execute it. Put it on a server with PHP (or a local stack like XAMPP) and access it via an http://localhost URL so PHP runs and returns HTML.
Can I convert a PHP file to HTML?
Not statically - but running the .php on a server produces HTML, which you can save with the browser's 'Save As' or with wget/curl against the live URL. You only capture one rendered snapshot; all dynamic logic and database calls are lost.
How do I run a PHP file on my own computer?
Install a local PHP stack - XAMPP or Laragon on Windows, MAMP on Mac - put the file in its web root and open it via http://localhost. Or install PHP alone and run 'php -S localhost:8000' in the folder, then browse to the file.
Is a .php file safe to open?
Opening it in an editor is safe - it's just text and won't run. The risk is in DEPLOYING an unknown .php to a live web server, where it executes; malicious scripts ('web shells') can compromise the whole site. Review any third-party PHP before running it.
What program opens functions.php in WordPress?
functions.php is a normal PHP theme file - edit it in VS Code or Notepad++ (or the WordPress theme-file editor, with caution). A syntax error there can white-screen the whole site, so edit a copy and keep a backup.

References

1PHP.net - official manual and downloadswww.php.net
2PHP supported versions / release roadmapwww.php.net

Keep exploring

across the database

Top extensions this week

1.AQQAQQ Instant Messenger File
2.CRDOWNLOADChrome Partial Download File
3.MDMarkdown Document
4.BINCD/DVD Disc Image (BIN/CUE)
5.PARTPartial Download File
6.RPMSGRestricted Permission Message
7.NOMEDIAAndroid No-Media Marker File
8.EXEWindows Executable (Portable Executable)
9.AVIFAV1 Image File Format (AVIF)
10.DBSQLite Database File

Related extensions

.CRDOWNLOADChrome Partial Download File
.JNLPJava Network Launch Protocol file
.WEBARCHIVESafari Web Archive
.PARTPartial Download File
.DOWNLOADPartial / Incomplete Download File
.ASPXActive Server Page Extended (ASP.NET Web Form)

Free file tools

An in-browser file identifier and image converter - everything runs on your device.

Open the toolbox

Browse file extensions A-Z