PHP

From Canonica AI

Introduction

PHP (Hypertext Preprocessor) is a widely-used open source general-purpose scripting language that is especially suited for web development and can be embedded into HTML. It is one of the first developed server-side scripting languages to be embedded into an HTML source document, rather than calling an external file to process data.

A screenshot of PHP code in a text editor.
A screenshot of PHP code in a text editor.

History

PHP was originally created by Rasmus Lerdorf in 1994. The main implementation of PHP is now produced by The PHP Group and serves as the formal reference to the PHP language. PHP originally stood for Personal Home Page, but it now stands for the recursive initialism PHP: Hypertext Preprocessor.

Syntax and semantics

PHP code is processed by an interpreter application in command-line mode performing desired operating system operations and producing program output on its standard output channel. It may also function as a graphical application. PHP is available as a processor for most modern web servers and as standalone interpreter on most operating systems and computing platforms.

Data types

PHP stores integers in a platform-dependent range, either a 64-bit or 32-bit signed integer equivalent to the C-language long type. Unsigned integers are converted to signed values in certain situations; this behavior is different from other programming languages. Floating point numbers are also stored in a platform-specific range. They can be specified using floating point notation, or two forms of scientific notation.

Functions

PHP has hundreds of base functions and thousands more from extensions. Functions are first-class citizens in PHP, meaning they can be stored in variables, passed as arguments to other functions, and returned as values from other functions. Functions are not compiled, but are parsed during runtime. They are named by a string, which can be stored in a variable and used to invoke the function at a later point.

Security

Security is a crucial aspect of any web application and PHP applications are no exception. PHP has a number of features designed to help protect web applications from attacks, such as SQL injection, cross-site scripting (XSS), and cross-site request forgery (CSRF). However, the effectiveness of these features depends largely on how they are used.

Usage

PHP is used by 79.1% of all the websites whose server-side programming language we know. This includes major websites like Facebook, Wikipedia, and WordPress. PHP is popular in part because it is easy to integrate with a variety of software and systems, including content management systems and e-commerce platforms.

Criticisms

Despite its popularity, PHP has been criticized for a number of reasons. These criticisms include its lack of an official specification until 2014, inconsistencies in its function naming and parameter ordering conventions, and a lack of native Unicode support at the character level.

See Also