PHP: Hypertext Preprocessor

PHP is a server-side scripting language designed for web development but also used as a general-purpose programming language. As of January 2013, PHP was installed on more than 240 million websites (39% of those sampled) and 2.1 million web servers.

PHP Logo

Originally created by Rasmus Lerdorf in 1994, the reference implementation of PHP is now produced by The PHP Group. While PHP originally stood for Personal Home Page, it now stands for PHP: Hypertext Preprocessor, a recursive backronym.

PHP code can be simply mixed with HTML code, or it can be used in combination with various templating engines and web frameworks. PHP code is usually processed by a PHP interpreter, which is usually implemented as a web server’s native module or a Common Gateway Interface (CGI) executable. After the PHP code is interpreted and executed, the web server sends resulting output to its client, usually in form of a part of the generated web page – for example, PHP code can generate a web page’s HTML code, an image, or some other data. PHP has also evolved to include a command-line interface (CLI) capability and can be used in standalone graphical applications.

PHP is free software released under the PHP License. PHP has been widely ported and can be deployed on most web servers on almost every operating system and platform, free of charge.

Release History

Syntax

Each PHP statement is terminated by semicolon (”;”). The PHP markup can display text by using “echo” with variables named by dollar-prefix “$” on case-sensitive names ($xx, $xX, $NewX, etc.). The assignment operator is “=”. The markup can be modularized into functions (or methods) defined with keyword “function” within optional classes named by “class xx”. The control structures include: if, while, for, foreach, & switch. Grouping of text can be specified by curly braces (”{…}”), but some control structures can use colon syntax with end keywords, such as in statement if ($x==0) : echo “zero”; endif;

The following Hello world program is written in PHP code embedded in an HTML document:

<!DOCTYPE html>
<html>
    <head>
        <title>PHP Test</title>
    </head>
    <body>
        <?php echo '<p>Hello World</p>'; ?> 
    </body>
</html>

Submit your open source PHP project for inclusion into our cross-referenced code library.