What is PHP?

PHP (Personal Home Page)

PHP - “PHP: Hypertext Preprocessor”, originally “Personal Home Page Tools”, is a general-purpose scripting language, used mainly for developing web applications. Currently supported by the vast majority of hosting providers it’s one of the leaders among the languages used to create dynamic websites. The language and its interpreter (Zend Engine) are developed by a group of enthusiasts within the framework of an open source project. The project is distributed under its own license, which is incompatible with the GNU GPL.

php

PHP is designed specifically for web development and its code can be implemented directly in HTML. Instead of routinely outputting HTML code with the help of language commands (as in Perl or C, for example), the PHP script contains HTML code with PHP commands. The PHP code is separated by special start and end tags “<?php” and “?>”, which allows coder to switch to PHP mode and exit it.

PHP differs from JavaScript in that PHP scripts are executed on the server and generate HTML code which is being send to the client. For example:

<?php
echo “Hello, World!”;
?>

If there’s a script on the server that resembles the above, the client would only receive the result of its execution, the line “Hello, World!”, but won’t be able to figure out what code produced it. The server can be configured in such a way that the usual HTML files will be processed by the PHP processor, so that clients won’t even be able to tell if they receive a regular HTML file or the result of running the script.

PHP is considered easy to learn, but at the same time it can satisfy the demands of professional web developers. Although PHP is mainly designed to work in a web server environment, its scope is not limited to this. The main area of the use of PHP is writing scripts that work on the server side. Thus, PHP is able to perform everything that any other scripting language does, for example, process form data, generate dynamic pages or send and receive cookies.

There are three main areas of PHP use:

  • Create scripts to run on the server side. PHP is traditionally and most widely used in this way.
  • Create scripts to run in the command line. This way of using PHP is ideally suited for scripts that need to be run regularly, for example, using cron (on Unix or Linux platforms) or using Task Scheduler on Windows platforms. These scripts can also be used in simple text processing tasks.
  • Creating graphical applications running on the client side. PHP is not the best language for creating applications, but if a programmer knows PHP very well and would like to use some of its features in client applications, he or she can use PHP-GTK to create such applications. Similarly, he or she can create cross-platform applications. PHP-GTK is a PHP extension and doesn’t come with the main PHP distribution.

PHP is available for most operating systems, including Linux, many Unix modifications (such as HP-UX, Solaris and BSD), Microsoft Windows, Mac OS X, and many others. Also, PHP includes support for most modern web servers, such as Apache, IIS, and many others. PHP can work as a module or function as a CGI processor.

Related terms:

HTML, CSS, JavaScript

References and further reading: