PHP is a server-side scripting language often used in conjunction with HTML in web development environments.
What is preprocessing?
Preprocessing is the act of evaluating code and running it before the page is delivered to the browser. As such, the content of the PHP code is never revealed by viewing the source code of a webpage within a browser, as it is replaced with the results of running the code before the page is sent to the browser to be rendered.
Why is it called PHP?
You might think that the “HP” part of the name stands for “Hypertext Preprocessor” and the second part of the full name is redundant. This was previously untrue; the original software was developed as a hobby by Rasmus Lerdorf in 1994 as a set of functions to help him maintain his personal home page. The name derives from that phrase — Personal Home Page — and so the suffix of Hypertext Preprocessor was in fact necessary. PHP has now become a backronym and stands for PHP: Hypertext Processor.
How PHP 7 arrived
The earliest versions of PHP were of course written for specific tasks that were required by the creator. It was not intended to be a general-purpose programming or scripting language. By 1996, a development team had formed, and functions were swiftly being added — unfortunately, due to the way it had been pieced together, not all the functions were consistent with the way they accepted parameters, or with how they produced results.
The late 90s saw PHP 3 and 4 released, building on the capabilities of PHP 2 (1996). PHP 5 arrived in 2004, and added support for databases, along with improved options for object-oriented programming. PHP 6 development was underway in 2006, along with an attempt to incorporate Unicode characters — which proved to be quite problematic. PHP 6 was never properly released due to these issues, and the version number was skipped as PHP 7 arrived in 2014.
PHP 7 included a whole host of new and improved features and is the current standard to which web development should adhere to.
How do you use PHP?
PHP can either be placed inside its own file type (.php) or embedded within an HTML file. When embedding, it is usually placed between two tags – < ?PHP and ?> with the end of internal lines marked with a semicolon. Here is an example:< ?PHP\ echo ‘This is a PHP instruction’;\ ?>
The “echo” function writes out the contents of the quoted text to the HTML file to be rendered. It supports the inclusion of variables, and HTML tags can be embedded:< ?PHP\ echo ‘This is a
**PHP instruction’;\ ?>
Wherein the output would be:
This is a PHP instruction
If the file is pure PHP (rather than an HTML file with PHP embedded), the closing tag can be omitted. This applies even if HTML has been placed within the PHP code as per the second example.
PHP can also be used as a command line tool, and as a programming language external to a webserver. However, by far the most common use is within web development, as it is a straightforward language to learn and has many practical applications.
What can it do?
PHP can be used for many task, as it is now a general-purpose scripting language. Simple tasks, such as mathematical calculations, can be performed easily, as can connecting to several types of database and the manipulation of the content and structure of such databases.
Will there be a PHP 8?
Generally speaking, most versions of PHP are backwards compatible, so code written in PHP 3 will run on a server with PHP 7. There are a few functions that have changed over time for various reasons (including re-ordering parameters to bring them into line with other functions) so in certain instances changes will have to be made.
There are no current plans for PHP 8, but as the project is open source and constantly receives updates and bug fixes, there is likely to be a new version in the future. This should remain compatible with (at the least) PHP 7 programs, as there is now little need to resolve and issues with parameter order and inconsistencies within functions.