![]() |
|
|
| |
|
||||
PHP (a recursive acronym for "PHP: Hypertext Preprocessor"; actually a retronym (see history)) is a widely-used open-source programming language primarily for server-side applications and developing dynamic web content. Famous examples of PHP applications include phpBB and MediaWiki, the software behind Wikipedia. The PHP model can be seen as an alternative to Microsoft's ASP/VBScript/JScript system, Macromedia's ColdFusion system, Sun Microsystems' JSP/Java system, and to the CGI/Perl system.
OverviewPHP's ease of use and similarity with the most common structured programming languages—most notably C and Perl (and from version 5, Java)—allows most experienced programmers to start developing complex applications with a minimal learning curve. It also enables experienced developers to get involved with dynamic web content applications without having to learn a whole new set of functions and practices. One of the more attractive parts of PHP is that it is more than just a scripting language. Due to its modular design, PHP is also used to develop GUI applications (using PHP-GTK), and can be used from the command line just like Perl or Python. PHP allows interaction with a large number of relational database systems, such as MySQL, Oracle, IBM DB2, Microsoft SQL Server, PostgreSQL and SQLite while maintaining a simple and straightforward syntax. PHP runs on most major operating systems, including UNIX, Linux, Windows, and Mac OS X, and can interact with many major web servers. The official PHP website (http://www.php.net/) contains extensive documentation (http://www.php.net/manual/). The Linux, Apache, MySQL, PHP (LAMP) architecture has become popular in the Web industry as a way of deploying inexpensive, reliable, scalable, secure web applications. (The 'P' in LAMP can also stand for Perl or Python.) PHP is the result of the collective efforts of many contributors. It is licensed under a BSD-style license, the PHP license. PHP, from version 4, has been powered by the Zend engine. HistoryPHP was originally designed as a small set of Perl scripts, followed by a rewritten set of CGI binaries written in C by Rasmus Lerdorf in 1994 to display his résumé and collect some data, such as how many hits it was generating. Others first used "Personal Home Page Tools" in 1995, when Lerdorf had combined it with his own Form Interpreter to create PHP/FI. Zeev Suraski and Andi Gutmans, two Israeli developers of the Technion - Israel Institute of Technology, rewrote the parser in 1997 and formed the base of PHP 3. They also changed the name to its current recursive form. After months in beta, the development team officially released PHP/FI 2 in November 1997. Public testing of PHP 3 began immediately and the official launch came in June 1998. Suraski and Gutmans then started a new rewrite of PHP's core, producing the Zend engine in 1999 (a page at www.zend.com (http://www.zend.com/zend/zend-engine-summary.php) states that PHP 3 was powered by Zend Engine 0.5). They also founded Zend Technologies in Ramat Gan, Israel which has since overseen the PHP advances. In May 2000, PHP 4, powered by the Zend Engine 1.0, was released. On July 13, 2004, PHP 5 was released, powered by Zend Engine II (formerly known as Zend Engine 2). PopularityPHP is currently one of the most popular server-side scripting systems on the Web. It has been widely adopted since the release of version 4, which was the first version powered by the powerful Zend Engine. One major part of PHP which has helped it become popular is that it is a very loose language; in particular, it is dynamically typed. That is, the rules aren't as strict with variables—they don't have to be declared and they can hold any type of object. Further, unlike many other languages (like C++ and Java), arrays are able to hold objects of varying types, including other arrays. According to Netcraft's April 2002 survey, PHP is now the most deployed server-side scripting language, running on around 9 of the 37 million domains in their survey. This is confirmed by PHP's own figures, which show PHP usage (measured on a per-domain basis) growing at around 5% per month. In May 2003, almost 13 million domains were using PHP, based on the same source.[1] (http://www.php.net/usage.php) Due to PHP's popularity, a new breed of programmer has emerged—one who is only familiar with PHP, which in turn forced open the door toward a command line interface for PHP, along with support for GUI library such as GTK+ and text mode libraries like Ncurses and Newt. This is a major step for PHP, because it represents its beginning adoption as a genuine programming language (i.e. running autonomously on a stand-alone machine, as opposed to its original purpose of serving web pages to client machines from a server). Many PHP programmers have reported having had trouble trying to learn other languages in the past and ultimately giving up after each attempt until attempting to learn PHP. The ease of programming in PHP has made it so these programmers are able to learn the basics of programming and are then able to continue on to other languages suchs as C/C++ or Perl/Python/Java and then finding themselves back programming in PHP for its speed of development in comparison to other languages. Code exampleHere is the Hello World code example:
<?php
echo "Hello, world!\n";
?>
Here is an example that prints out the lyrics for the song 99 Bottles of Beer:
<?php
/*
* /* ... */ is a comment that can span one or many lines.
* Other ways of commenting are // and # symbols.
* This kind of comment does not need stars (*) in the beginning of each line,
* but including them is a common practice. // and # are also comments.
* They only comment the text that are after them in the same line. They have
* no special ending character.
*
*/
/*
* First we define a new function called "plural".
* It will return an "s" if the argument passed to it was any other
* than number 1.
*/
function plural($number) {
return ($number != 1 ? "s" : "");
// The ternary ?: operator is similar to if-else: (test_condition ? true : false)
// In this case it's used to return "" for one and "s" for all other numbers
}
// We define a variable called $lb to contain an HTML line break
// as well as a carriage return and line feed:
$lb = "<br />\r\n";
for ($i = 99; $i > 0; $i--) {
echo $i . " bottle" . plural($i) . " of beer on the wall," . $lb;
// We don't actually need a new echo for each line. Let's see:
echo $i . " bottle" . plural($i) . " of beer." . $lb . "
Take one down, pass it around," . $lb .
($i - 1 != 0 ? $i - 1 : "no more") .
" bottle" . plural($i - 1) . " of beer on the wall" . $lb . $lb;
}
echo "Go to the store," . $lb . "buy some more," . $lb .
"99 bottles of beer on the wall!";
?>
Notes:
LibrariesPHP includes a large number of free and open-source libraries with the core build. PHP is a fundamentally Internet-aware system with modules built in for accessing FTP servers, many database servers, embedded SQL libraries like embedded MySQL and SQLite, LDAP servers, and others. Many functions familiar to C programmers such as the printf family are available in the standard PHP build. PHP extensions exist which, among other features, add support for the Windows API, process management on UNIX-like operating systems, cURL, and the ZIP/gzip/bzip2/rar/lzf compression formats. Some of the more unusual features are on-the-fly Macromedia Flash generation, integration with Internet relay chat, and generation of dynamic images (where the content of the image can be changed). Some additional extensions are available via the PHP Extension Community Library (PECL). This is the present list of all officially documented libraries: (Source: PHP.net manual (http://www.php.net/manual/en/)) Object-oriented programmingUp until version 3, PHP had no object-oriented features. In version 3 basic object functionality was added. The same semantics were implemented in PHP 4 as well as pass-by-reference and return-by-reference for objects but the implementation still lacked the powerful and useful features of other object-oriented languages like C++ and Java. In version 5, which was released in July 2004, PHP's object-oriented functionality has been very much enhanced and is more robust and complete. Here is a summary of some of the changes in PHP 5 (powered by Zend Engine II (http://www.zend.com/php5/)):
More additions and examples of the additions mentioned above are available on this page (http://www.php.net/zend-engine-2.php). It is should be noted that the static method and class variable features in Zend Engine 2 do not work the way some expect. There is no virtual table feature in the Engine, so the static variables are bound with a name at compile time instead of with a reference. This can lead to unexpected behavior, if you do not understand this. CriticismCriticism of PHP includes those general criticisms ascribed to other scripting programming languages and dynamically typed languages. In addition, specific criticism of PHP includes: Syntax
Built-in functions
Security
Miscellaneous
SupportPHP is self-supporting with respect to user support. Direct, one-to-one help is frequently provided free of charge through all of these and other media. PHP users assist each other through various media such as chat, forums, newsgroups and PHP developer web sites. In turn, the PHP development team actively participates in such communities, garnering assistance from them in their own development effort (PHP itself) and providing assistance to them as well. There are many help resources available for the novice PHP programmer. These resources include:
Applications built with PHPThe following is a list of notable applications developed using PHP:
External linksPHP home site
Advocacy
Frameworks
Integrated development environments, debuggers and other tools
Security
Tutorials
Articles and other resources
Miscellaneous
|
|||||||||
|
|
|||||||||
|
|
|
|
Copyright 2008 WordIQ.com - Privacy Policy
::
Terms of Use
:: Contact Us
:: About Us This article is licensed under the GNU Free Documentation License. It uses material from the Wikipedia article "PHP". |