Computerhelp4all logo Articles AboutTopicsQuizzesComputer Questions & AnswersComputer Terms & DefinitionsActivitiesContact

What Is PHP?

What Is PHP

Date First Published: 9th August 2022

Topic: Web Design & Development

Subtopic: Web Development

Article Type: Computer Terms & Definitions

Difficulty: Medium

Difficulty Level: 5/10

Learn more about what PHP is in this article.

PHP is a widely used server-side scripting language that is embedded in HTML pages and used in web development. PHP is often used to create dynamic content, interact with databases, and perform calculations. It was introduced by Rasmus Lerdorf in 1994 and released to the public on 8th June 1995. By default, PHP is installed on web servers with Apache software along with MySQL. Originally, PHP stood for Personal Home Page, but it was later changed to become a recursive acronym 'PHP: Hypertext Preprocessor' in version 3 the next year. This was because of the extended tools in version 2. The 'elePHPant' is the mascot of the PHP project, designed by Vincent Pontier. Over 75% of websites use PHP on the server side. Facebook, Wikipedia, WordPress, and Tumblr all use PHP.

An example of a simple PHP script that outputs the text 'Basic PHP Script' onto a HTML page can be seen below.

<!DOCTYPE html> <html lang="en"> <head> <title>PHP Script Example.</title> </head> <body> <?php echo "Basic PHP Script"; ?> </body> </html>

This PHP script will simply return the specified text in a web browser. Because PHP is a server-side scripting language, it will not work without web server software installed and does not run on the client side.

What Can PHP Be Used For?

PHP can be used to perform all sorts of server-side functions on a website, including:

  • Communicating with databases, such as MySQL and creating, opening, reading, writing, and deleting data. This is often used to store and process user-generated content.
  • Generating dynamic web content, such as content that automatically changes based on user behaviour, preferences, and interests.
  • Building ecommerce sites and other web-based applications. For example, WordPress is completely written in PHP.
  • Setting, deleting, and modifying cookies.
  • Handle data entered in forms. (e.g. save entered data to a file or a database, send entered data to an email address in a contact form)
  • Managing user access levels. (e.g. restricting user access to some pages)
  • Building login systems where users can sign in by entering a username and a password.
  • Performing filesystem actions, such as reading, creating, and writing to files.
  • Encrypting data.

File Extensions

HTML documents with PHP script embedded in them with the <?php and ?> tags have the file extension '.php' or '.phtml'. They do not have the file extension '.html' even though they show HTML in the source code. PHP can sometimes have the file extension '.php3', '.php4', and '.php5' to represent the PHP version used.

Note: Info Icon

Because PHP is a server-side scripting language, it is run at the web server before it is delivered to the end-user. This means that the PHP source code cannot be viewed in a web browser and only the HTML output produced by the PHP scripts can be seen. The PHP code is processed by a PHP engine on the web server in order to dynamically generate HTML.

Advantages and Disadvantages Of PHP

The advantages of PHP are:
  • It is open-source, meaning that is freely useable by anyone and does not require payment in order for it to be used. That is the biggest advantage.
  • Since it runs on the web server rather than the browser, it will run faster on slower computers.
  • It is compatible with a wide range of operating systems, including Windows, Linux, macOS, Unix, and web servers, including Apache IIS, etc.
  • It is flexible and can be combined with a lot of other programming and markup languages, such as HTML.
  • It gives the web developer more control in comparison to other programming languages as other ones are often restricted to long and complex scripts. However, for PHP, a few simple lines of code are sufficient and PHP is written between tags, so functions and codes don't have to be written in a certain order as long as they are within the tags.
The disadvantages of PHP are:
  • There are some security risks - Since PHP is open-source, vulnerabilities can be found and exploited much more easily, some of which can perform malicious actions, such as stealing sensitive information. Examples of vulnerabilities include cross-site scripting, SQL injection, and session hijacking.
  • There is a lack of debugging tools that are essential for identifying errors and warnings. Developers believe that PHP comes with a poor quality of handling errors.

PHP Versions

PHP Logo
PHP Logo
  • PHP 4 - This version was powered by the Zend Engine 1.0. By August 2008, version 4.4.9 was reached. PHP 4 is no longer developed and no more security updates will be released.
  • PHP 5 - This version was released on 1st July 2004 and powered by the Zend Engine II. PHP 5 added new features, such as support for object-oriented programming, the PHP Data Objects extension that defines a lightweight and consistent interface for accessing databases, and a number of performance enhancements.
  • PHP 6 - This version was supposed to add Unicode support to PHP and represented a huge change. The International Components for Unicode (ICU) library was integrated into PHP in 2005 as part of a project led by Andrei Zmievski, and text strings were internally represented as UTF-16. It was intended to release this as version 6.0 of the language along with other enhancements that were then under development because it would completely change both the internals of the language and user code.
  • PHP 7 - This release is considered to be the most important change for PHP after the introduction of PHP 5 in 2004. It added support for return type declarations, nullable parameter types scalar type declarations for strings, floating-point numbers, integers, and booleans.
  • PHP 8 - Released on 26th November 2020, this version has some modifications from the previous versions, including just-in-time compilation, addition of the match expression, and various syntax changes and type changes.


Feedback

  • Is there anything that you disagree with on this page?
  • Are there any spelling, grammatical, or punctuation errors on this page?
  • Are there any broken links or design errors on this page?

If so, it is important that you tell me as soon as possible on this page.