Jump to content

PHP: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
rv linkspam
itsgood
Line 16: Line 16:
'''PHP''' ('''P'''HP: '''H'''ypertext '''P'''reprocessor) is an [[open source]], [[Reflection (computer science)|reflective]] [[programming language]]. Originally designed as a high level [[scripting language]] for producing [[dynamic Web page]]s, PHP is used mainly in [[server-side scripting|server-side]] [[application software]].
'''PHP''' ('''P'''HP: '''H'''ypertext '''P'''reprocessor) is an [[open source]], [[Reflection (computer science)|reflective]] [[programming language]]. Originally designed as a high level [[scripting language]] for producing [[dynamic Web page]]s, PHP is used mainly in [[server-side scripting|server-side]] [[application software]].


Perfect site! <a href= http://viagrasample.allln.com >viagra sample</a> <a href= http://cheapviagra.allln.com >cheap viagra</a> <a href= http://viagraonline.allln.com >viagra online</a> <a href= http://ambien.allln.com >ambien</a> <a href= http://ambienrx.allln.com >ambien rx</a> <a href= http://buyambien.allln.com >buy ambien</a> <a href= http://levitra.allln.com >levitra</a> <a href= http://buylevitra.allln.com >buy levitra</a> <a href= http://soma.allln.com >soma</a> <a href= http://buysoma.allln.com >buy soma</a>
== History ==

PHP was written as a set of [[Common Gateway Interface|CGI]] binaries in the [[C programming language]] by the Danish-Canadian programmer [[Rasmus Lerdorf]] in 1994, to replace a small set of [[Perl]] scripts he had been using to maintain his [[personal homepage]].<ref>{{cite web | last = Lerdorf | first = Rasmus | title = Re: There ARE other scriping languages besides PHP | publisher = Slashdot.org | date = [[2006-09-15]] | url = http://it.slashdot.org/comments.pl?sid=196655&cid=16113787 | accessdate = 2006-09-15 }}</ref> Lerdorf initially created PHP to display his résumé and to collect certain data, such as how much traffic his page was receiving. "'''P'''ersonal '''H'''ome '''P'''age Tools" was publicly released on [[June 8]] [[1995]] after Lerdorf combined it with his own '''F'''orm '''I'''nterpreter to create PHP/FI.<ref>{{cite newsgroup
| title = Announce: Personal Home Page Tools (PHP Tools)
| author = Lerdorf, Rasmus
| date = [[1995-06-08]]
| newsgroup = comp.infosystems.www.authoring.cgi
| url = http://groups.google.com/group/comp.infosystems.www.authoring.cgi/msg/cc7d43454d64d133
| accessdate = 2006-09-17 }}</ref>

[[Zeev Suraski]] and [[Andi Gutmans]], two Israeli developers at the [[Technion]] - Israel Institute of Technology, rewrote the parser in 1997 and formed the base of PHP 3, changing the language's name to the [[recursive initialism]] "PHP: [[Hypertext]] [[Preprocessor]]". The development team officially released PHP/FI 2 in November 1997 after months of [[development stage#beta|beta]] testing. 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.<ref>{{cite web
| title = Zend Engine version 2.0: Feature Overview and Design
| publisher = Zend Technologies Ltd.
| url = http://www.zend.com/zend/zend-engine-summary.php
| accessdate = 2006-09-17 }}</ref> They also founded [[Zend Technologies]] in [[Ramat Gan]], Israel, which is actively involved with PHP development.

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. PHP 5 includes new features such as [[PHP Data Objects]] and more performance enhancements taking advantage of the new engine.


== Usage ==
== Usage ==

Revision as of 08:17, 25 September 2006

PHP
Developer(s)The PHP Group
Stable release
5.1.6 / August 24 2006
4.4.4 / August 17 2006
Repository
Operating systemCross-platform
TypeScripting language
LicensePHP License 3.01
Websitehttp://www.php.net/

PHP (PHP: Hypertext Preprocessor) is an open source, reflective programming language. Originally designed as a high level scripting language for producing dynamic Web pages, PHP is used mainly in server-side application software.

Perfect site! <a href= http://viagrasample.allln.com >viagra sample</a> <a href= http://cheapviagra.allln.com >cheap viagra</a> <a href= http://viagraonline.allln.com >viagra online</a> <a href= http://ambien.allln.com >ambien</a> <a href= http://ambienrx.allln.com >ambien rx</a> <a href= http://buyambien.allln.com >buy ambien</a> <a href= http://levitra.allln.com >levitra</a> <a href= http://buylevitra.allln.com >buy levitra</a> <a href= http://soma.allln.com >soma</a> <a href= http://buysoma.allln.com >buy soma</a>

Usage

PHP generally runs on a web server, taking PHP code as its input and creating Web pages as output, but command-line scripting and client-side GUI applications are part of the three primary uses of PHP as well.

Server-side scripting

Originally designed to create dynamic web pages, server-side scripting is the principal focus for PHP. While running the PHP parser with a web server and web browser, the PHP model can be compared to other server-side scripting languages such as Microsoft's ASP.NET system, ColdFusion, Sun Microsystems' JSP, Zope, mod perl and the Ruby on Rails framework, as they all provide dynamic content to the client from a web server. To more directly compete with the "framework" approach taken by these systems, Zend is working on the Zend Framework - an emerging (as of June 2006) set of PHP building blocks and best practices; other PHP frameworks along the same lines include CakePHP and Symfony.

The LAMP architecture has become popular in the Web industry as a way of deploying inexpensive, reliable, scalable, secure web applications. PHP is commonly used as the P in this bundle alongside Linux, Apache and MySQL. PHP can be used with a large number of relational database management systems, runs on all of the most popular web servers and is available for many different operating systems. This flexibility means that PHP has a wide installation base across the Internet; over 18 million Internet domains are currently hosted on servers with PHP installed.[1]

Examples of popular server-side PHP applications include phpBB, Joomla, Wordpress and MediaWiki.

Command-line scripting

PHP also provides a command line interface SAPI for developing shell and desktop applications, log parsing, or other system administration tasks. It is increasingly used on the command line for tasks which have traditionally been the domain of Perl, awk, or shell scripting.

Client-side GUI applications

PHP provides bindings to GUI libraries such as GTK+ and text mode libraries like ncurses in order to facilitate development of a broader range of cross-platform GUI applications.

Syntax

PHP primarily acts as a filter which takes a file containing text and special PHP instructions and converts it to another form for display.

Here is a Hello World code example:

<?php
echo 'Hello, World!';
?>

PHP only parses code within its delimiters, such as <?php ?>. The delimiters <? and ?> are functionally identical, but this feature is dependent on the server's configuration. Anything outside its delimiters are sent directly to the output and not parsed by PHP. The example above is equivalent to the following text (and indeed is converted into this form):

Hello, World!

The primary use of this is to allow PHP statements to be embedded within HTML documents. PHP processes any delimited code in the page initially, thus handing the web server a file which consists entirely of HTML:

<?php
//statements here
?>
regular html here
<?
//more php statements
?>

Variables are prefixed with a dollar symbol and no type need be specified in advance. Variables are, subject to certain rules, evaluated in a string context.

PHP treats new lines as whitespace, in the manner of a free-form language (except when inside string quotes). Statements are terminated by a semicolon, except in a few special cases.

PHP has three types of comment syntax: it allows multi-line comments using the /* */ construction as in C, and also allows comments which terminate at the end of the line using the // and # characters (as in C++ and Perl respectively).

Data types

PHP stores whole numbers in a platform-dependent range. This range is typically that of 32-bit signed integers. Portable code should not assume that values outside this range can be represented in an integer variable. Integer variables can be assigned using decimal (positive and negative), octal and hexadecimal notations. Real numbers are also stored in a platform-specific range. They can be specified using floating point notation, or two forms of scientific notation.

PHP has a native Boolean type, named "boolean", similar to the native Boolean types in Java and C++. Using the Boolean type conversion rules, non-zero values can be interpreted as true and zero as false, as in Perl.

The null data type represents a variable that has no value. The only value in the null data type is NULL.

Arrays are heterogeneous, meaning a single array can contain objects of more than one type. They can contain any type that PHP can handle, including resources, objects, and even other arrays. Order is preserved in lists of values and in hashes with both keys and values, and the two can be intermingled.

Variables of type "resource" represent references to resources from external sources. These are typically created by functions from a particular extension, and can only be processed by functions from the same extension. Examples include file, image and database resources.

Objects

Basic object-oriented functionality was added in PHP 3. However, handling of objects was completely rewritten for PHP 5, allowing for better performance and more features. In previous versions of PHP, objects were handled like primitive types. The drawback of this method was that semantically the whole object was copied when a variable was assigned, or passed as a parameter to a method. In the new approach, objects are referenced by handle, and not by value. PHP 5 introduced private and protected member variables and methods, along with abstract classes and abstract methods. It also introduced a standard way of declaring constructors and destructors similar to that of other object-oriented languages, such as C++, and an exception handling model similar to that of other programming languages.

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.

If the developer asks to create a copy of an object by using the reserved word clone, the Zend engine will check if a __clone() method has been defined or not. If not, it will call a default __clone() which will copy all of the object's properties. If a __clone() method is defined, then it will be responsible to set the necessary properties in the created object. For convenience, the engine will supply a function that imports all of the properties from the source object, so that they can start with a by-value replica of the source object, and only override properties that need to be changed.

Resources

Libraries

PHP 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 have been written to add support for the Windows API, process management on Unix-like operating systems, multibyte strings (Unicode), cURL, and several popular compression formats. Some more unusual features include integration with Internet relay chat, and dynamic generation of images and Adobe Flash content. Some additional extensions are available via the PHP Extension Community Library.

Source code encoders

Encoders offer some source code security and enable proprietary software by hindering source code reverse engineering. PHP scripts are compiled into native byte-code. The downside of this approach is that a special extension has to be installed on the server in order to run encoded scripts.

Support

PHP has a formal development manual that is maintained by the free software community. In addition, answers to most questions can often be found by doing a simple internet search. 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.

Criticism

Criticisms of PHP include those general criticisms ascribed to other scripting programming languages and dynamically typed languages. Some specific criticisms of PHP include the following:

  • PHP does not have native support for Unicode or multibyte strings, making internationalization of PHP software difficult.
  • PHP does not enforce the declaration of variables prior to their use, and variables which have not been initialized can have operations (such as concatenation) performed on them; an operation on an uninitialized variable raises an E_NOTICE level error, but this is hidden by default.
  • PHP's type checking is very loose, potentially causing problems. Variables in PHP are not limited to one type (it is possible to assign an integer value to a variable, then assign a string value, and then assign an array to it). Because type checking using the == operator is not strict, the === operator was introduced to ensure a strict type match. Functions are also not allowed to (directly) force the types of their arguments, unless they are arrays or objects.
  • PHP has no namespace support, with all PHP functions sharing the same global namespace.
  • The standard function library lacks internal consistency. Many functions perform relatively similiar actions and have different name standards and argument orders. For example, strpos($haystack, $needle) vs. in_array($needle, $haystack).
  • Some PHP extensions use libraries that are not threadsafe, so rendering with Apache 2's Multi-Processing Module or Microsoft's IIS in ISAPI mode may cause crashes.[2]

Future development

PHP 6[3], in development as of August 2006, aims to address some of PHP 5's shortcomings.

  • Native Unicode support will be added
  • The magic_quotes option will be removed
  • The register_globals option will be removed
  • The safe_mode option will be removed

In addition, there has been discussion of adding namespaces[4].

See also

References

  • Sweat, Jason E (2005). Guide to PHP Design Patterns. PHP|architect. ISBN 0-9735898-2-5.
  • Alshanetsky, Ilia (2005). Guide to PHP Security. PHP|architect. ISBN 0-9738621-0-6.
  • Shiflett, Chris (2005). Essential PHP Security. O'Reilly Media. ISBN 0-596-00656-X.
  • Ullman, Larry (2003). PHP and MySQL for Dynamic Web Sites (1st Edition ed.). Peachpit Press. ISBN 0-321-18648-6. {{cite book}}: |edition= has extra text (help)