What is PHP

Summary: in this tutorial, you’ll learn about PHP, how it works, what it can do, and its advantages.

Introduction to PHP

PHP is a server-side and general-purpose scripting language that is especially suited for web development.

PHP originally stood for Personal Home Page. However, now, it stands for Hypertext Preprocessor. It’s a recursive acronym because the first word itself is also an acronym.

PHP was created by Rasmus Lerdorf in 1994. It’s currently maintained by the PHP Development Team.

PHP is a server-side language

When you open a website on your web browser, for example, https://www.phptutorial.net

The web browser sends an HTTP request to a web server where phptutorial.net locates. The web server receives the request and responds with an HTML document.

In this example, the web browser is a client while the web server is the server. The client requests for a page, and the server serves the request.

PHP runs on the web server, processes the request, and returns the HTML document.

PHP is a general-purpose language

When it comes to the purpose of the programming languages, there are two main types: domain-specific and general-purpose languages.

The domain-specific languages are used within specific application domains. For example, SQL is a domain-specific language. It’s used mainly for querying data from relational databases. And SQL cannot be used for other purposes.

On the other hand, PHP is a general-purpose language because PHP can develop various applications.

PHP is a cross-platform language

PHP can run on all major operating systems, including Linux, Windows, and macOS.

You can use PHP with all leading web servers such as Nginx, OpenBSD, and Apache. Some cloud environments also support PHP like Microsoft Azure and Amazon AWS.

PHP is quite flexible. It’s not just limited to processing HTML. PHP has built-in support for generating PDF, GIF, JPEG, and PNG images.

One notable feature of PHP is that it supports many databases, including MySQL, PostgreSQL, MS SQL, db2, Oracle Database, and MongoDB.

What can PHP do

PHP has two main applications:

  • Server-side scripting – PHP is well-suited for developing dynamic websites and web applications.
  • Command-line scripting – like Python and Perl, you can run PHP script from the command line to perform administrative tasks like sending emails and generating PDF files.

The tutorials on this website mainly focus on server-side scripting.

How PHP Works

The following illustrates how PHP works:

How PHP works:

  • First, the web browser sends an HTTP request to the web server, e.g., index.php.
  • Second, the PHP preprocessor that locates on the web server processes PHP code to generate the HTML document.
  • Third, the web server sends the HTML document back to the web browser.

Advantages of PHP

Since PHP is designed for the web in the first place, it brings many advantages to web development:

  • Simple – PHP is quite easy to learn and get started.
  • Fast – PHP websites typically run very fast.
  • Stable – PHP is stable since it has been in existence for a long time.
  • Open-source and free – PHP is open source and free. It means that you don’t have to pay a license fee to use PHP to develop software products.
  • Community support – PHP has an active online community that helps you whenever you face an issue.
Did you find this tutorial useful?