What Is PHP
PHP as a Server-Side Language
What is PHP? It is a server-side scripting language built for web development. The name is a recursive acronym for PHP: Hypertext Preprocessor, and the language began as a set of tools for personal home pages.
A PHP file mixes ordinary HTML with PHP code placed between special tags. When a visitor requests the page, the server's PHP engine runs the code, which may read a database or process a form submission, and then sends the finished HTML to the browser. The visitor never sees the PHP source.
How a PHP Page Becomes HTML
The process has a few clear steps. The web server receives the request and sees that the file ends in .php, so it passes the file to the PHP engine. The engine runs the script and outputs text, which is normally HTML. The web server then returns that output to the browser as the response.
The code can do many things along the way: check a login, fetch products from a database, format a date or include a header shared by every page. Because the code runs on each request, the same file can produce different pages for different visitors.
The way PHP connects to the web server is covered in PHP-FPM and FastCGI, and the comparison with another server-side language is in PHP vs Node.js.
Why Shared Hosting Commonly Supports PHP
PHP has been widely available on web hosts for many years, and it is the language behind several large content management systems, including WordPress, Drupal and Joomla. A host that supports these platforms usually provides PHP as a standard service.
PHP fits shared hosting well because many sites can run on one server, each with its own scripts. Limits on memory, run time and upload size are set by the host and the PHP configuration, which helps limit the effect one busy site has on the others.
Frequently asked questions
Is PHP still relevant for web development?
Yes. PHP powers a large share of websites, particularly content management systems and shared-hosting sites. Modern PHP is a mature language with a large ecosystem and active maintenance. Supported versions receive security fixes, so the version a site runs matters as much as the language itself. See PHP versions for more.
Do I need to know PHP to use WordPress?
Not for everyday use. WordPress lets you publish content through a visual dashboard. PHP becomes relevant when you install, customise or troubleshoot the software, because the server must run a compatible PHP version and the site's themes and plugins may depend on it.