• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
24307183 php
 

24307183 php

on

  • 628 views

 

Statistics

Views

Total Views
628
Views on SlideShare
628
Embed Views
0

Actions

Likes
0
Downloads
6
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    24307183 php 24307183 php Document Transcript

    • PHP, or PHP: Hypertext Preprocessor, is a widely used, general-purpose scripting languagethat was originally designed for web development, to produce dynamic web pages. It can beembedded into HTML and generally runs on a web server, which needs to be configured toprocess PHP code and create web page content from it. It can be deployed on most webservers and on almost every operating system and platform free of charge.[2] PHP is installedon over 20 million websites and 1 million web servers.[3]PHP was originally created by Rasmus Lerdorf in 1995 and has been in continuousdevelopment ever since. The main implementation of PHP is now produced by The PHPGroup and serves as the de facto standard for PHP as there is no formal specification.[4] PHPis free software released under the PHP License, which is incompatible with the GNUGeneral Public License (GPL) because of restrictions on the use of the term PHP.[5]PHP has evolved to include a command line interface capability and can also be used instandalone graphical applications.[6]HistoryPHP originally stood for personal home page.[4] It began in 1994 as a set of CommonGateway Interface binaries written in the C programming language by theDanish/Greenlandic programmer Rasmus Lerdorf.[7][8] Lerdorf initially created these PersonalHome Page Tools to replace a small set of Perl scripts he had been using to maintain hispersonal homepage. The tools were used to perform tasks such as displaying his résumé andrecording how much traffic his page was receiving.[4] He combined these binaries with hisForm Interpreter to create PHP/FI, which had more functionality. PHP/FI included a largerimplementation for the C programming language and could communicate with databases,enabling the building of simple, dynamic web applications. Lerdorf released PHP publicly onJune 8, 1995 to accelerate bug location and improve the code.[9] This release was named PHPversion 2 and already had the basic functionality that PHP has today. This included Perl-likevariables, form handling, and the ability to embed HTML. The syntax was similar to Perl butwas more limited, simpler, and less consistent.[4]Zeev Suraski and Andi Gutmans, two Israeli developers at the Technion IIT, rewrote theparser in 1997 and formed the base of PHP 3, changing the languages name to the recursiveinitialism PHP: Hypertext Preprocessor.[10] The development team officially released PHP/FI2 in November 1997 after months of beta testing. Afterwards, public testing of PHP 3 began,and the official launch came in June 1998. Suraski and Gutmans then started a new rewrite ofPHPs core, producing the Zend Engine in 1999.[11] They also founded Zend Technologies inRamat Gan, Israel.[4]On May 22, 2000, PHP 4, powered by the Zend Engine 1.0, was released.[4] As of August,2008 this branch is up to version 4.4.9. PHP 4 is no longer under development nor will anysecurity updates be released.[12][13] On July 13, 2004, PHP 5 was released, powered by the newZend Engine II.[4] PHP 5 included new features such as improved support for object-orientedprogramming, the PHP Data Objects extension (which defines a lightweight and consistentinterface for accessing databases), and numerous performance enhancements.[14] In 2008,PHP 5 became the only stable version under development. Late static binding has beenmissing from PHP and has been added in version 5.3.[15][16] PHP 6 is under developmentalongside PHP 5. Major changes include the removal of register_globals,[17] magicquotes, and safe mode.[12][18] The reason for the removals was that register_globals had givenway to security holes, and magic quotes had an unpredictable nature, and was best avoided.Instead, to escape characters, magic quotes may be substituted with the addslashes() function,or more appropriately an escape mechanism specific to the database vendor itself like
    • mysql_real_escape_string() for MySQL. Functions that will be removed in PHP 6 have beendeprecated in PHP 5.3 and will produce a warning if used.[19]Many high-profile open-source projects ceased to support PHP 4 in new code as of February5, 2008, because of the GoPHP5 initiative, provided by a consortium of PHP developerspromoting the transition from PHP 4 to PHP 5.[20][21]PHP currently does not have native support for Unicode or multibyte strings; Unicodesupport will be included in PHP 6 and will allow strings as well as class, method and functionnames to contain non-ASCII characters.[22][23]It runs in both 32-bit and 64-bit environments, but on Windows the only official distributionis 32-bit, requiring Windows 32-bit compatibility mode to be enabled while using IIS in a 64-bit Windows environment. As of PHP 5.3.0, experimental x64 bit versions are available Officially called "Personal Home Page Tools (PHP Tools)". This is the first use of1995-06- the name "PHP08 (1.0 version) Namespace support; Late static bindings, Jump label (limited goto), Native closures, Native PHP archives (phar), garbage collection for circular references, improved2009- Windows support, Persistent connections with mysqli, sqlite3, fileinfo as a06-30 replacement for mime_magic for better MIME support, Ternary shortcut and the Internationalization extension. Removal of ereg extension. (5.3 version)UsagePHP is a general-purpose scripting language that is especially suited for web development.PHP generally runs on a web server. Any PHP code in a requested file is executed by thePHP runtime, usually to create dynamic web page content. It can also be used for command-line scripting and client-side GUI applications. PHP can be deployed on most web servers,many operating systems and platforms, and can be used with many relational databasemanagement systems. It is available free of charge, and the PHP Group provides the completesource code for users to build, customize and extend for their own use.[2]PHP primarily acts as a filter,[32] taking input from a file or stream containing text and/or PHPinstructions and outputs another stream of data; most commonly the output will be HTML.Since PHP 4, the PHP parser compiles input to produce bytecode for processing by the ZendEngine, giving improved performance over its interpreter predecessor.[33]Originally designed to create dynamic web pages, PHP now focuses mainly on server-sidescripting,[34] and it is similar to other server-side scripting languages that provide dynamiccontent from a web server to a client, such as Microsofts Active Server Pages, SunMicrosystems JavaServer Pages,[35] and mod_perl. PHP has also attracted the development ofmany frameworks that provide building blocks and a design structure to promote rapid
    • application development (RAD). Some of these include CakePHP, Symfony, CodeIgniter,and Zend Framework, offering features similar to other web application frameworks.The LAMP and WAMP architectures have become popular in the web industry as a way ofdeploying web applications. PHP is commonly used as the P in this bundle alongside Linux,Apache and MySQL, although the P may also refer to Python or Perl.As of April 2007, over 20 million Internet domains were hosted on servers with PHPinstalled, and mod_php was recorded as the most popular Apache module.[36] Significantwebsites are written in PHP including the user-facing portion of Facebook,[37] Wikipedia(MediaWiki),[38] Yahoo!,[39] MyYearbook,[40] Digg, Joomla, WordPress, YouTube in its earlystages, Drupal and Tagged.[41][edit] SecurityThe National Vulnerability Database stores all vulnerabilities found in computer software.The overall proportion of PHP-related vulnerabilities on the database amounted to: 20% in2004, 28% in 2005, 43% in 2006, 36% in 2007, and 35% in 2008.[42] Most of these PHP-related vulnerabilities can be exploited remotely: they allow hackers to steal or destroy datafrom data sources linked to the webserver (such as an SQL database), send spam orcontribute to DOS attacks using malware, which itself can be installed on the vulnerableservers.These vulnerabilities are caused mostly by not following best practice programming rules:technical security flaws of the language itself or of its core libraries are not frequent (23 in2008, about 1% of the total). [43][44] Recognizing that programmers cannot be trusted, somelanguages include taint checking to detect automatically the lack of input validation whichinduces many issues. Such a feature is being developed for PHP,[45] but its inclusion in arelease has been rejected several times in the past.[46][47]Hosting PHP applications on a server requires a careful and constant attention to deal withthese security risks.[48] There are advanced protection patches such as Suhosin and Hardening-Patch, especially designed for web hosting environments.[49] Installing PHP as a CGI binaryrather than as an Apache module is the preferred method for added securitySyntaxPHP only parses code within its delimiters. Anything outside its delimiters is sent directly tothe output and is not processed by PHP. The most common delimiters are <?php to open and?> to close PHP sections. <script language="php"> and </script> delimiters are alsoavailable, as are the shortened forms <? or <?= (which is used to echo back a string orvariable) and ?> as well as ASP-style short forms <% or <%= and %>. While short delimitersare used, they make script files less portable as their purpose can be disabled in the PHPconfiguration, and so they are discouraged.[50] The purpose of all these delimiters is toseparate PHP code from non-PHP code, including HTML.[51]The first form of delimiters, <?php and ?>, in XHTML and other XML documents, createscorrectly formed XML processing instructions.[52] This means that the resulting mixture ofPHP code and other markup in the server-side file is well-formed XML.Variables are prefixed with a dollar symbol and a type does not need to be specified inadvance. Unlike function and class names, variable names are case sensitive. Both double-
    • quoted ("") and heredoc strings allow the ability to embed a variables value into the string.[53]PHP treats newlines as whitespace in the manner of a free-form language (except when insidestring quotes), and statements are terminated by a semicolon.[54] PHP has three types ofcomment syntax: /* */ marks block and inline comments; // as well as # are used for one-line comments.[55] The echo statement is one of several facilities PHP provides to output text(e.g. to a web browser).In terms of keywords and language syntax, PHP is similar to most high level languages thatfollow the C style syntax. If conditions, for and while loops, and function returns aresimilar in syntax to languages such as C, C++, Java and Perl.Data typesPHP stores whole numbers in a platform-dependent range. This range is typically that of 32-bit signed integers. Unsigned integers are converted to signed values in certain situations; thisbehavior is different from other programming languages.[56] Integer variables can be assignedusing decimal (positive and negative), octal, and hexadecimal notations. Floating pointnumbers are also stored in a platform-specific range. They can be specified using floatingpoint notation, or two forms of scientific notation.[57] PHP has a native Boolean type that issimilar to the native Boolean types in Java and C++. Using the Boolean type conversionrules, non-zero values are interpreted as true and zero as false, as in Perl and C++.[57] The nulldata type represents a variable that has no value. The only value in the null data type isNULL.[57] Variables of the "resource" type represent references to resources from externalsources. These are typically created by functions from a particular extension, and can only beprocessed by functions from the same extension; examples include file, image, and databaseresources.[57] Arrays can contain elements of any type that PHP can handle, includingresources, objects, and even other arrays. Order is preserved in lists of values and in hasheswith both keys and values, and the two can be intermingled.[57] PHP also supports strings,which can be used with single quotes, double quotes, or heredoc syntax.[58]The Standard PHP Library (SPL) attempts to solve standard problems and implementsefficient data access interfaces and classes.[59][edit] FunctionsPHP has hundreds of base functions and thousands more via extensions. These functions arewell documented on the PHP site, however, the built-in library has a wide variety of namingconventions and inconsistencies. PHP currently has no functions for thread programming,although it does support multiprocess programming on POSIX systems[60].[edit] 5.2 and earlierFunctions are not first-class functions and can only be referenced by their name, directly ordynamically by a variable containing the name of the function. [61] User-defined functions canbe created at any time without being prototyped.[61] Functions can be defined inside codeblocks, permitting a run-time decision as to whether or not a function should be defined.Function calls must use parentheses, with the exception of zero argument class constructorfunctions called with the PHP new operator, where parentheses are optional. PHP supportsquasi-anonymous functions through the create_function() function, although they are nottrue anonymous functions because anonymous functions are nameless, but functions can onlybe referenced by name, or indirectly through a variable $function_name();, in PHP
    • ObjectsBasic object-oriented programming functionality was added in PHP 3 and improved in PHP4.[4] Object handling was completely rewritten for PHP 5, expanding the feature set andenhancing performance.[62] In previous versions of PHP, objects were handled like primitivetypes.[62] The drawback of this method was that the whole object was copied when a variablewas assigned or passed as a parameter to a method. In the new approach, objects arereferenced by handle, and not by value. PHP 5 introduced private and protected membervariables and methods, along with abstract classes and final classes as well as abstractmethods and final methods. It also introduced a standard way of declaring constructors anddestructors, similar to that of other object-oriented languages such as C++, and a standardexception handling model. Furthermore, PHP 5 added interfaces and allowed for multipleinterfaces to be implemented. There are special interfaces that allow objects to interact withthe runtime system. Objects implementing ArrayAccess can be used with array syntax andobjects implementing Iterator or IteratorAggregate can be used with the foreach languageconstruct. There is no virtual table feature in the engine, so static variables are bound with aname instead of a reference at compile time.[63]If the developer creates a copy of an object using the reserved word clone, the Zend enginewill check if a __clone() method has been defined or not. If not, it will call a default__clone() which will copy the objects properties. If a __clone() method is defined, then itwill be responsible for setting the necessary properties in the created object. For convenience,the engine will supply a function that imports the properties of the source object, so that theprogrammer can start with a by-value replica of the source object and only overrideproperties that need to be changed.[64][edit] Speed optimizationAs with many scripting languages, PHP scripts are normally kept as human-readable sourcecode, even on production web servers.[65] In this case, PHP scripts will be compiled at runtimeby the PHP engine, which increases their execution speed. PHP scripts are able to becompiled before runtime using PHP compilers as with other programming languages such asC (the language PHP and its extensions are written in).Code optimizers aim to reduce the runtime of the compiled code by reducing its size andmaking other changes that can reduce the execution time with the goal of improvingperformance. The nature of the PHP compiler is such that there are often opportunities forcode optimization,[66] and an example of a code optimizer is the eAccelerator PHP extension.[67]Another approach for reducing overhead for high load PHP servers is using an Opcode cache.Opcode caches work by caching the compiled form of a PHP script (opcodes) in sharedmemory to avoid the overhead of parsing and compiling the code every time the script runs.An opcode cache, APC, will be built into PHP 6.[68] Opcode caching is also available in ZendServer Community Edition.[edit] ResourcesPHP includes free and open source libraries with the core build. PHP is a fundamentallyInternet-aware system with modules built in for accessing FTP servers, many databaseservers, embedded SQL libraries such as embedded PostgreSQL, MySQL and SQLite, LDAPservers, and others. Many functions familiar to C programmers such as those in the stdiofamily are available in the standard PHP build.[69] PHP has traditionally used features such as"magic_quotes_gpc" and "magic_quotes_runtime" which attempt to escape apostrophes ()and quotes (") in strings in the assumption that they will be used in databases, to prevent SQLinjection attacks. This leads to confusion over which data is escaped and which is not, and to
    • problems when data is not in fact used as input to a database and when the escaping used isnot completely correct.[70] To make code portable between servers which do and do not usemagic quotes, developers can preface their code with a script to reverse the effect of magicquotes when it is applied.[71]PHP allows developers to write extensions in C to add functionality to the PHP language.These can then be compiled into PHP or loaded dynamically at runtime. Extensions havebeen written to add support for the Windows API, process management on Unix-likeoperating systems, multibyte strings (Unicode), cURL, and several popular compressionformats. Some more unusual features include integration with Internet Relay Chat, dynamicgeneration of images and Adobe Flash content, and even speech synthesis. The PHPExtension Community Library (PECL) project is a repository for extensions to the PHPlanguage.[72]Zend provides a certification exam for programmers to become certified PHP developers