According to php.net, "PHP is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML."
PHP ("PHP Hypertext Preprocessor") – is programming language for dynamic Web-page generation by scripts run on Web-server. You create pages using PHP and HTML. It is important to understand that PHP is a server-side technology, unlike Javascript and other client-side technologies that execute the code in the browser; PHP code is executed on the server. To test a PHP script, it needs to be copied to the server and run there. When site visitor opens a page, server executes php code embedded into html code and sends results to visitor’s browser, the same way as in ASP or ColdFusion. However unlike ASP or ColdFusion PHP is an Open Source and cross-platform product. PHP runs on Windows NT, W2K and *nix systems. It can work as Apache module or as an independent executable program using CGI. PHP runs really well and fast as Apache module. In this case server resources usage for thread creation is minimized; results are generated faster.
Apart from different content operations on your pages, using PHP you can also form HTTP-headers, set cookies, manage authentications and redirects. PHP has excellent database support (and ODBC) and easily integrates with third party libraries. You can do virtually anything from PDF document creation to parsing XML data.
PHP operators are inserted directly into your Web-pages, thus eliminating the need in special development tools (IDE). You simply start PHP block with <?php tag and end with ?> tag. (You can configure PHP to use an ASP style tags: <% %> or something like this <SCRIPT LANGUAGE="php"></SCRIPT>.) Everything between those tags will be considered PHP code.
<html> <head> <title>Example</title> </head> <body> <?php echo "Hello, World!"; ?> </body> </html> |
PHP syntax is similar to C and Perl syntax. PHP supports the basic data types of strings, integers, double precision floating point numbers, etc, but is a weakly typed language. This means that variables are not tied to a specific data type, and may take any of the data types. Variables are not declared in PHP, but must be prefixed with a $ sign. Instructions are separated the same as in C or perl - terminate each statement with a semicolon.
The closing tag (?>) also implies the end of the statement, so the following are equivalent:
<?php echo "This is a test"; ?> <?php echo "This is a test" ?> |
PHP even has some basic support of object oriented programming providing convenient ways of code arrangement and encapsulation.
At the most basic level, PHP can do anything any other CGI program can do, such as collect form data, generate dynamic page content, or send and receive cookies.
Perhaps the strongest and most significant feature in PHP is its support for a wide range of databases. Writing a database-enabled web page is incredibly simple. The following databases are currently supported:
| Adabas D |
Ingres |
Oracle (OCI7 and OCI8) |
| dBase |
InterBase |
Ovrimos |
| Empress |
FrontBase |
PostgreSQL |
| FilePro (read-only) |
mSQL |
Solid |
| Hyperwave |
Direct MS-SQL |
Sybase |
| IBM DB2 |
MySQL |
Velocis |
| Informix |
ODBC |
Unix dbm |
Adabas D Ingres Oracle (OCI7 and OCI8)
dBase InterBase Ovrimos
Empress FrontBase PostgreSQL
FilePro (read-only) mSQL Solid
Hyperwave Direct MS-SQL Sybase
IBM DB2 MySQL Velocis
Informix ODBC Unix dbm
PHP also has support for talking to other services using protocols such as IMAP, SNMP, NNTP, POP3, HTTP and countless others. You can also open raw network sockets and interact using other protocols.
Although PHP works best under Apache on PHP site you can find installation instructions for Microsoft IIS and Netscape Enterprise Server. You can download PHP distributive from its official web site. Technical documentation with full description can also be found there.
Recommended IDEs/text editors for PHP:
ZendStudio - http://www.zend.com/store/products/zend-studio.php
HomeSite - http://www.macromedia.com/software/homesite/
PHPCoder - http://www.phpide.com/go/programs/php_coder.htm
EditPlus - http://www.editplus.com/