Browse Definitions :
Definition

PHP (Hypertext Preprocessor)

What is PHP (Hypertext Preprocessor)?

PHP (Hypertext Processor) is a general-purpose scripting language and interpreter that is freely available and widely used for web development. The language is used primarily for server-side scripting, although it can also be used for command-line scripting and, to a limited degree, desktop applications. The acronym PHP was originally derived from Personal Home Page Tools, but it now stands for PHP: Hypertext Preprocessor, which the PHP Group's documentation describes as a "recursive acronym."

When used for server-side scripting, PHP is added to a webpage for the purpose of generating dynamic content when the page is accessed through a client browser. The web server runs the script before transmitting the page to the browser. To support this process, the web server requires PHP to be installed on the server, along with a PHP parser -- either a Common Gateway Interface (CGI) parser or a server module.

When a user requests a webpage from the server, the parser interprets the PHP portion of the page, performs the operations called for in the PHP script, and generates the Hypertext Markup Language (HTML) that results from those operations. The HTML is then sent to the client browser, along with any other HTML on the page, providing a seamless rendering of the content. Webpages that contain PHP script are considered to be dynamic HTML pages because content varies based on the results of interpreting the script.

Working with PHP for server-side scripting

A webpage might be made up entirely of a PHP script, or it might contain one or more PHP scripts that are embedded within standard HTML elements. In either case, the webpage itself typically is assigned the .php file extension, which informs the web server that the page contains PHP script. The following code provides an example of a simple HTML page named test.php that contains an embedded PHP script that presents the day's date:

<!DOCTYPE html>
<html>

<head>
  <title>HTML example</title>
</head>

<body>
  <h2>Example of HTML in action</h2>
  <?php
    $text =  "This is a test HTML script.";

    $date = date("M j, Y") ;
   
echo $text." Today's date is <b>".$date."</b>."
  ?>
</body>

</html>

Most of the page's content is basic HTML that includes standard <head> and <body> elements. However, the <body> section also contains a PHP script, which is enclosed in the PHP start and end tags -- <?php and ?>, respectively. PHP scripts must always be enclosed in these tags, whether they take up the entire page or are embedded as the one shown here.

The script in this example defines the $text variable, which is assigned a string value, and the $date variable, which is assigned the current date retrieved through the date function. The two variable definitions are followed by an echo statement that concatenates the variables, along with additional text. PHP uses a period (.) to concatenate multiple elements. The echo statement also incorporates standard HTML markup -- <b> and </b> -- which specifies that the date should be displayed in bold text.

When a client browser accesses the test.php page, the web server and PHP parser read the PHP script and return regular HTML. This figure shows the webpage as it is displayed in the Google Chrome browser. The text beneath the main heading has been generated by the PHP script.

heading generated by the PHP script
Test webpage displayed in Google Chrome with the text beneath the main heading generated by the PHP script

Most major operating systems support PHP, including Linux, macOS, Windows and many Unix variants, as do most of today's web servers, such as Apache and Microsoft Internet Information Services. PHP can also interface with a wide range of database platforms, including MySQL, SQLite3, MongoDB, dBase, PostgreSQL and IBM Db2. In addition, PHP can communicate with other services through its support for protocols such as Lightweight Directory Access Protocol, Internet Message Access Protocol and Simple Network Management Protocol.

PHP is often contrasted with Microsoft's ASP.NET, an open source web framework. As with ASP.NET, a PHP script can be embedded within a webpage along with HTML elements.

PHP is free and open source. Developers can find the source code on GitHub. PHP is currently licensed under the PHP License, version 3.01, which provides for its use in both source and binary forms, with or without modifications. The license also outlines specific conditions that must be met in order to use PHP. These mostly have to do with copyright notices, the use of the PHP name and general acknowledgements. The latest release of PHP is 8.2.3, which became available in February 2023.

See eight PHP features that prove it's for more than just the web.

This was last updated in April 2023

Continue Reading About PHP (Hypertext Preprocessor)

Networking
  • subnet (subnetwork)

    A subnet, or subnetwork, is a segmented piece of a larger network. More specifically, subnets are a logical partition of an IP ...

  • Transmission Control Protocol (TCP)

    Transmission Control Protocol (TCP) is a standard protocol on the internet that ensures the reliable transmission of data between...

  • secure access service edge (SASE)

    Secure access service edge (SASE), pronounced sassy, is a cloud architecture model that bundles together network and cloud-native...

Security
  • cyber attack

    A cyber attack is any malicious attempt to gain unauthorized access to a computer, computing system or computer network with the ...

  • digital signature

    A digital signature is a mathematical technique used to validate the authenticity and integrity of a digital document, message or...

  • What is security information and event management (SIEM)?

    Security information and event management (SIEM) is an approach to security management that combines security information ...

CIO
  • product development (new product development)

    Product development -- also called new product management -- is a series of steps that includes the conceptualization, design, ...

  • innovation culture

    Innovation culture is the work environment that leaders cultivate to nurture unorthodox thinking and its application.

  • technology addiction

    Technology addiction is an impulse control disorder that involves the obsessive use of mobile devices, the internet or video ...

HRSoftware
  • organizational network analysis (ONA)

    Organizational network analysis (ONA) is a quantitative method for modeling and analyzing how communications, information, ...

  • HireVue

    HireVue is an enterprise video interviewing technology provider of a platform that lets recruiters and hiring managers screen ...

  • Human Resource Certification Institute (HRCI)

    Human Resource Certification Institute (HRCI) is a U.S.-based credentialing organization offering certifications to HR ...

Customer Experience
  • contact center agent (call center agent)

    A contact center agent is a person who handles incoming or outgoing customer communications for an organization.

  • contact center management

    Contact center management is the process of overseeing contact center operations with the goal of providing an outstanding ...

  • digital marketing

    Digital marketing is the promotion and marketing of goods and services to consumers through digital channels and electronic ...

Close