PHP is a server side scripting language. This means that programmes in PHP are included in amongst the normal text of HTML pages and that these programs are executed by a PHP enabled WWW server. The output from the programs is included in the HTML page text as a replacement for the original PHP programme.
PHP is most commonly associated with the Apache WWW server and is almost certainly the most widely used scripting language on the WWW. The commonest current version is PHP 4, but PHP 5 is widely available. Full information is available on the WWW at www.php.net
The PHP language is strongly based on C (not C++) in the Unix environment, there are also significant influences from perl and the Unix scripting language awk. Anyone familiar with C++ and contemplating using PHP will need to understand the differences between C++ and C. Anyone familiar with C, particularly under Unix, and awk or perl will find PHP remarkably intuitive and easy to use. You might want to follow this link to read more about C and its differences from C++.
One of the great strengths of PHP is the inclusion of a very large number of library routines. These include a more or less complete set of Unix system calls and native mode access to a large variety of databases including Oracle and MySQL. Unfortunately, many of the groups of functions are optional and may not necessarily be available in a particular implementation. For details examine the PHP local environment example in the notes.
To activate PHP interpretation of files before sending them to clients an Apache server will normally be configured to recognise files with names ending in .php. Within such files PHP interpretation is applied to code contained within the markers <? and ?>. This is a slightly unfortunate choice as various other mark-up schemes such as those related to XML use the same markers. There can be several such marked regions within a page, they all form part of the same PHP program. The acceptable file name suffixes and the PHP markers can vary slightly depending on PHP build time options.
The PHP programming language includes, as might be expected, variables of various types, arrays (both conventional and content addressable), functions and flow control structures (if/then, for, do etc.,). It has the same set of operators as C. PHP is an object oriented programming language with most of the standard mechanisms but does not come with any standard classes.
If an error occurs during the interpretation of a PHP program then an error message is included in the generated HTML and is included in the page displayed to the browser user, this is useful for debugging in contrast to the tendency of the CGI mechanism to generate totally unhelpful error messages.
PHP variables differ in some respects from those encountered in most procedural programming language. They do not require specific declaration but simply spring into existence when first referenced in a manner familiar to programmers familiar with languages such as Basic and Fortran. Of course this does mean that extra care needs to be taken over their naming as the effect of a simple typing error can be to convert a reference to one variable to a reference to a different variable. PHP variable names always start with the symbol $. PHP variables do not have types, a trait PHP shares with many interpreted languages, the silly practice of starting a variable name with a letter indicating its type is, thus, totally irrelevant to PHP programming.
When a PHP variable springs into existence it will have a "null" or "zero" value unless it has been, effectively, defined in the environment. Environment defined variables represent data items whose value can be determined by the host WWW server either directly (e.g. the IP address of the requesting client) or from the "dynamic" part of the requested URL (this includes values acquired by the forms mechanism).