PHP: Hypertext Preprocessor is a widely used, general-purpose scripting language that was originally designed for web development to produce dynamic web pages. For this purpose, PHP code is embedded into the HTML source document and interpreted by a web server with a PHP processor module, which generates the web page document. As a general-purpose programming language, PHP code is processed by an interpreter application in command-line mode performing desired operating system operations and producing program output on its standard output channel. It may also function as a graphical application. PHP is available as a processor for most modern web servers and as a standalone interpreter on most operating systems and computing platforms.
PHP was originally created by Rasmus Lerdorf in 1995 and has been in continuous development ever since. The main implementation of PHP is now produced by the PHP Group and serves as the de facto standard for PHP as there is no formal specification. PHP is free software released under the PHP License.
History
PHP originally stood for personal home page.
He rewrote these scripts as C programming languageCommon Gateway Interface (CGI) binaries, extending them to add the ability to work with web forms and to communicate with databases and called this implementation 'Personal Home Page/Forms Interpreter' or PHP/FI. PHP/FI could be used to build simple, dynamic web applications. Lerdorf released PHP/FI as 'Personal Home Page Tools (PHP Tools) version 1.0' publicly on June 8, 1995, to accelerate bug location and improve the code. This release already had the basic functionality that PHP has today. This included Perl-like variables, form handling, and the ability to embed HTML. The syntax was similar to Perl but was more limited and simpler, although less consistent. They also founded Zend Technologies in Ramat Gan, Israel.
On July 13, 2004, PHP 5 was released, powered by the new Zend Engine II.
In 2008 PHP 5 became the only stable version under development. Late static binding had been missing from PHP and was added in version 5.3.
A new major version has been under development alongside PHP 5 for several years. This version was originally planned to be released as PHP 6 as a result of its significant changes, which included plans for full Unicode support. However, Unicode support took developers much longer to implement than originally thought, and the decision was made in March 2010 to move the project to a branch, with features still under development moved to a trunk.
Changes in the new code include the removal of register_globals, magic quotes, and safe mode. The reason for the removals was that register_globals had given way to security holes, and the use of magic quotes had an unpredictable nature, and was best avoided. Instead, to escape characters, magic quotes may be replaced 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 future versions and have been deprecated in PHP 5.3 will produce a warning if used.
Many high-profile open-source projects ceased to support PHP 4 in new code as of February 5, 2008, because of the GoPHP5 initiative, provided by a consortium of PHP developers promoting the transition from PHP 4 to PHP 5.
PHP currently does not have native support for Unicode or multibyte strings; Unicode support is under development for a future version of PHP and will allow strings as well as class, method, and function names to contain non-ASCII characters.
PHP interpreters are available on both 32-bit and 64-bit operating systems, but on Microsoft Windows the only official distribution is a 32-bit implementation, requiring Windows 32-bit compatibility mode while using Internet Information Services (IIS) on a 64-bit Windows platform. As of PHP 5.3.0, experimental 64-bit versions are available for MS Windows.
Licensing
PHP is free software released under the PHP License, which insists that:
4. Products derived from this software may not be called "PHP", nor
may "PHP" appear in their name, without prior written permission
from group@php.net. You may indicate that your software works in
conjunction with PHP by saying "Foo for PHP" instead of calling
it "PHP Foo" or "phpfoo"
This restriction on use of the name PHP makes it incompatible with the GNU General Public License (GPL).
Release history
{| class="wikitable"
|-
!
! Meaning
|-
| style="background:salmon;" | Red
| Release no longer supported
|-
| style="background:#a0e75a;" | Green
| Release still supported
|-
| style="background:skyBlue;" | Blue
| Future release
|}
{| class="wikitable"
|-
! Major version !! Minor version !! Release date !! Notes
|-
!1
| style="background:salmon;" | 1.0.0
|
|Officially called "Personal Home Page Tools (PHP Tools)". This is the first use of the name "PHP".
|-
| style="background:salmon;" | 4.1.0
|
|Introduced 'superglobals' ($_GET, $_POST, $_SESSION, etc.)
|-
| style="background:salmon;" | 4.4.0
|
|Added man pages for phpize and php-config scripts.
|-
| style="background:salmon;" | 4.4.9
|
|More security enhancements and bug fixes. The last release of the PHP 4.4 series.
|-
!rowspan="11"|5
| style="background:salmon;" | 5.0.0
|
|Zend Engine II with a new object model.
|-
| style="background:salmon;" | 5.1.0
|
|Performance improvements with introduction of compiler variables in re-engineered PHP Engine.
|-
| style="background:salmon;" | 5.3.0
|
|Namespace support; Late static bindings, Jump label (limited goto), Native closures, Native PHP archives (phar), garbage collection for circular references, improved Windows support, sqlite3, mysqlnd as a replacement for libmysql as underlying library for the extensions that work with MySQL, fileinfo as a replacement for mime_magic for better MIME support, the Internationalization extension, and deprecation of ereg extension.
|-
| style="background:salmon;" | 5.3.1
|
|Over 100 bug fixes, some of which were security fixes as well.
|-
| style="background:salmon;" | 5.3.2
|
| Includes a large number of bug fixes.
|-
| style="background:#a0e75a;" | 5.3.3
|
| Mainly bug and security fixes; FPM.
|-
! php-trunk-dev
| style="background:skyBlue;" | ?.?
|No date set
|Removed items: 'register_globals', 'safe_mode', 'allow_call_time_pass_reference', session_register(), session_unregister() and session_is_registered() functions
New features: traits, array dereferencing, closure $this support, JsonSerializable interface
|}
PHP primarily acts as a filter, taking input from a file or stream containing text and/or PHP instructions and outputs another stream of data; most commonly the output will be HTML. Since PHP 4, the PHP parsercompiles input to produce bytecode for processing by the Zend Engine, giving improved performance over its interpreter predecessor.
The LAMP architecture has become popular in the web industry as a way of deploying 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 or some combination of the three. WAMP packages (Windows/ Apache/ MySQL / PHP) and MAMP packages (Macintosh / Apache / MySQL / PHP) are also available.
As of April 2007, over 20 million Internet domains had web services hosted on servers with PHP installed and mod_php was recorded as the most popular Apache HTTP Server module.
Significant websites are written in PHP including the user-facing portion of Facebook, Wikipedia (MediaWiki), Digg, Joomla, eZ Publish, WordPress, Drupal and Moodle.
Security
The National Vulnerability Database maintains a list of vulnerabilities found in computer software.
The overall proportion of PHP-related vulnerabilities on the database amounted to: 20% in 2004, 28% in 2005, 43% in 2006, 36% in 2007, 35% in 2008, and 30% in 2009. Most of these PHP-related vulnerabilities can be exploited remotely: they allow attackers to steal or destroy data from data sources linked to the webserver (such as an SQLdatabase), send spam or contribute to DoS attacks using malware, which itself can be installed on the vulnerable servers.
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 in 2008, about 1% of the total).
Recognizing that programmers cannot be trusted, some languages include taint checking to detect automatically the lack of input validation which induces many issues.
Such a feature is being developed for PHP, but its inclusion in a release has been rejected several times in the past.
Hosting PHP applications on a server requires a careful and constant attention to
deal with these security risks.
There are advanced protection patches such as Suhosin and Hardening-Patch, especially designed for web hosting environments.
PHP only parses code within its delimiters. Anything outside its delimiters is sent directly to the output and is not processed by PHP (although non-PHP text is still subject to control structures described within PHP code). The most common delimiters are to open and ?> to close PHP sections. and delimiters are also available, as are the shortened forms or = (which is used to echo back a string or variable) and ?> as well as ASP-style short forms <% or <%= and %>. While short delimiters are used, they make script files less portable as support for them can be disabled in the PHP configuration, and so they are discouraged. The purpose of all these delimiters is to separate PHP code from non-PHP code, including HTML.
The first form of delimiters, and ?>, in XHTML and other XML documents, creates correctly formed XML 'processing instructions'. This means that the resulting mixture of PHP code and other markup in the server-side file is itself well-formed XML.
Variables are prefixed with a dollar symbol and a type does not need to be specified in advance. Unlike function and class names, variable names are case sensitive. Both double-quoted ("") and heredoc strings allow the ability to embed a variable's value into the string. PHP treats newlines as whitespace in the manner of a free-form language (except when inside string quotes), and statements are terminated by a semicolon. PHP has three types of comment syntax: /* */ marks block and inline comments; // as well as # are used for one-line comments. 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 that follow the C style syntax. if conditions, for and while loops, and function returns are similar in syntax to languages such as C, C++, Java and Perl.
Data types
PHP stores whole numbers in a platform-dependent range, either a 64-bit or 32-bit signedinteger equivalent to the C-language long type. Unsigned integers are converted to signed values in certain situations; this behavior is different from other programming languages. Integer variables can be assigned using decimal (positive and negative), octal, and hexadecimal notations. Floating point 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 that is similar to the native Boolean types in Java and C++. Using the Boolean type conversion rules, non-zero values are interpreted as true and zero as false, as in Perl and C++.
The Standard PHP Library (SPL) attempts to solve standard problems and implements efficient data access interfaces and classes.
Functions
PHP has hundreds of base functions and thousands more via extensions. These functions are well documented on the PHP site; however, the built-in library has a wide variety of naming conventions and inconsistencies. PHP currently has no functions for thread programming, although it does support multiprocess programming on POSIX systems.
PHP 5.2 and earlier
Functions are not first-class functions and can only be referenced by their name, directly or dynamically by a variable containing the name of the function. User-defined functions can be created at any time without being prototyped. The drawback of this method was that 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 final classes as well as abstract methods and final methods. It also introduced a standard way of declaring constructors and destructors, similar to that of other object-oriented languages such as C++, and a standard exception handling model. Furthermore, PHP 5 added interfaces and allowed for multiple interfaces to be implemented. There are special interfaces that allow objects to interact with the runtime system. Objects implementing ArrayAccess can be used with array syntax and objects implementing Iterator or IteratorAggregate can be used with the foreachlanguage construct. There is no virtual table feature in the engine, so static variables are bound with a name instead of a reference at compile time.
If the developer creates a copy of an object 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 the object's properties. If a __clone() method is defined, then it will 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 the programmer can start with a by-value of the source object and only override properties that need to be changed.
Basic example of object-oriented programming as described above:
class Person {
public $first;
public $last;
public function __construct($f, $l) {
$this->first = $f;
$this->last = $l;
}
public function greeting() {
return "Hello, my name is {$this->first} {$this->last}.";
}
static public function staticGreeting($first, $last) {
return "Hello, my name is {$first} {$last}.";
}
}
$him = new Person('John', 'Smith');
$her = new Person('Sally', 'Davis');
echo $him->greeting(); // prints "Hello, my name is John Smith."
echo ' ';
echo $her->greeting(); // prints "Hello, my name is Sally Davis."
echo ' ';
echo Person::staticGreeting('Jane', 'Doe'); // prints "Hello, my name is Jane Doe."
Visibility of properties and methods
The visibility of PHP properties and methods refers to visibility in PHP. It is defined using the keywords "public," "private," and "protected." The default is public, if only var is used; "var" is a synonym for "public." "Public" declared items can be accessed everywhere. "Protected" limits access to inherited classes (and to the class that defines the item). "Private" limits visibility only to the class that defines the item. Objects of the same type have access to each other's private and protected members even though they are not the same instance. PHP's member visibility features have sometimes been described as "highly useful." However, they have also sometimes been described as "at best irrelevant and at worst positively harmful."
Speed optimization
PHP source code is compiled on-the-fly to an internal format that can be executed by the PHP engine. In order to speed up execution time and not have to compile the PHP source code every time the webpage is accessed, PHP scripts can also be deployed in executable format using a PHP compiler.
Code optimizers aim to reduce the runtime of the compiled code by reducing its size and making other changes that can reduce the execution time with the goal being improving performance. The nature of the PHP compiler is such that there are often opportunities for code optimization, and an example of a code optimizer is the eAccelerator PHP extension.
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 shared memory to avoid the overhead of parsing and compiling the code every time the script runs. An opcode cache, APC, will be built into an upcoming release of PHP. Opcode caching is also available in Zend Server Community Edition.
Compilers
The PHP language was originally implemented using a PHP interpreter. Several compilers now exist, which decouple the PHP language from the interpreter:
phc - a C++ based compiler for PHP, using the Zend run-time for maximum compatibility
Roadsend - achieves native compilation by compiling to bigloo scheme, which in turn is compiled to C, then to machine code
Raven - a rewrite of Roadsend PHP (rphp), based on LLVM and a new C++ runtime
Phalanger - compiles source code written in the PHP scripting language into CIL byte-code
HipHop - developed at Facebook and now available as open source, transforms the PHP Script into C++, then compiles it.
php-to-scala - converts PHP to human-readable Scala source code, which the developer can compile to Java bytecode
Advantages of compilation include not only better execution speed, but also obfuscation, static analysis, and improved interoperability with code written in other languages.
Resources
PHP includes free and open source libraries with the core build. PHP is a fundamentally Internet-aware system with modules built in for accessing servers, many database servers, embedded SQL libraries such as embedded PostgreSQL, MySQL and SQLite, LDAP servers, and others. Many functions familiar to C programmers such as those in the stdio family are available in the standard PHP build.
Creating a standard webpage template, only the content changes when a link is clicked. Saves time duplicating each file, and makes it a lot easier if something needs to be changed, like a menu item, header, or footer.
Get started with PHP by installing a webserver with PHP and MySQL support. For ease of use and convenience, i'll be showing you how to install XAMPP available from www.apachefriends.org
To get php and apache installed use xampp. xampp is free and contains php / apache (around 33mb) 1. Download and Install XAMPP from here: www.apachefriends.org 2. on windows go to C:\xampp it should have a folder called htdocs. If you put a file called foo.html into the htdocs folder you should be able to access it by going to localhost or /foo.php. There's also something called WAMP www.wampserver.com There's a lot of php tutorials out there just search google www.google.com Request tutorials here youtube.jimmyr.com More PHP TUtorials here killerphp.com Some people have recommended other editors www.scintilla.org www.pspad.com en.wikipedia.org www.context.cx %%programming
PHP Tutorials: Register & Login: User login (Part 1)
Part of the 'Register & Login' Project from PHP Academy. This tutorials walks you through how to process a username and password based login against details found in a database, set a session, and process a logout function.
This PHP tutorial shall cover a BASIC authentication script enabling authorised users access to a specific website. A more advanced and recommended script for authentication is covered in my 4th tutorial (video response). Visit www.rascal999.co.uk for more information.
Check this video out at Hi-Res here: www.tutvid.com Files are Located here: www.tutvid.com In the following tutorial we will start with a few html files and we will build an Email Handling PHP script that sends info from your web form to your email! It is pretty easy PHP so enjoy learning and Have fun! I am using Dreamweaver CS3, but you can use pretty much any version of Dreamweaver, just follow closely and try not to make mistakes. Please enjoy and don't forget to check out the site www.tutvid.com
Gregg Pollack from EnvyLabs.com and Jason Seifer from http do some Ruby on Rails commercials in the same style of the Mac vs PC ads. Videos produced by Jason Hawkins of MakeFilmWork.com.
Splits a full name into two seperate variables. Useful for signup forms where you just want to ask the user their full name, and not have two seperate boxes for first and last names.
A PHP and HTML Tutorial in which we processes information from a form using the $_POST[]; functions in PHP and created a table and form. Link for Notepad2: www.flos-freeware.ch
www.helpvid.net ----------------------------- GET THE PHP SCRIPT HERE http How to create a contact form in Dreamweaver using a PHP script to send the form to your mail. PHP script When a message is sent the contact page contacts this PHP script, its here all our Email details are stored and we tell the Scrip exactly how we want the message to appear and to where we want it sent {your personal email account}. Be sure and drop by the website helpvid.net
PHP Tutorials: Register & Login: User login (Part 2)
Part of the 'Register & Login' Project from PHP Academy. This tutorials walks you through how to process a username and password based login against details found in a database, set a session, and process a logout function.
XAMPP - Make your Computer a Webserver: Apache, PHP, MySQL
XAMPP is a free installer that has Apache / PHP / MYsql / perl and more integrated so you won't have to configure anything yourself. HTML / CSS Tutorial youtube.com Basic PHP Tutorial youtube.com Free Webhosts blog.jimmyr.com Update DynDNS is supposed to help if you have a dynamic IP, hadn't tried it though. sides xampp there's also wamp and this one vertrigo.sourceforge.net @@@{ "Group": "Programming" }
This PHP tutorial elaborates on my second PHP tutorial which covers authentication. This PHP tutorial covers a more advanced PHP script which allow/denies users access to a specific website. Visit www.rascal999.co.uk for more info, tutorials and forum! Apologies for the belch half way through, I was unaware I uploaded that version of the tutorial ;) Please view the video response as it helps prevent possible SQL attack on your database(s)
Visit the forum for help! phpacademy.info Follow on Twitter! twitter.com Paginating results from a MySQL database. This is a (almost) simple method of showing paginated results effectively.
Arrays allow you to store a number of data values inside one variables, which makes it easier to read, quicker to assign and easier to access each element!
Professional Database Development www.comentum.com code @ www.gorilla3d.com UPDATE: ------------------------------- How do you create the database for this tutorial? Php 09: phpMyAdmin www.youtube.com Sorry for the confusion
PLEASE CHECK OUT THE SECOND VIDEO OF THIS A quick and easy user registration using php, sql and phpmyadmin. For full size and source codes: www.neoblob.com SQL: CREATE TABLE `user` ( `id` int(10) unsigned NOT NULL auto_increment, `username` varchar(20) NOT NULL default '', `password` varchar(50) NOT NULL default '', `email` varchar(40) NOT NULL default '', `ip` varchar(20) NOT NULL default '', PRIMARY KEY (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
Reasons for choosing PHP for WEB Development services
photo: Creative Commons / Flickr upload bot
March3.J27.UFPJ.WDC.27jan07
photo: Creative Commons / Elvert Barnes
March3.J27.UFPJ.WDC.27jan07
photo: AP / Pat Roque
A teller, behind bars for her protection, counts U.S. dollars for exchange at a money changer's shop Friday, Nov. 21, 2008 in Manila at the current rate of Php 50.18 to US$1.
photo: U.S. Army/Spc. Mike Pryor
Staff Sgt. Matthew Sheppard from the 325th Airborne Infantry Regiment, patrols Lwar Kowndalan, Afghanistan by donkey (visit http://www4.army.mil/ocpa/read.php?story_id_key=8046). This photo appeared on www.army.mil.
You down with PHP? (Yeah, and Ruby) The surveying snoops at Evans Data say developers that use PHP are more satisfied with the scripting language overall than those who program with Ruby, Perl,...
"My biggest disappointment with PHP is that I did not learn it sooner." -post in newsgroup comp.lang.php, May, 2003 "We have something that is significant for your developers... something that will...
The Daily TelegraphHealthcare property investor Primary Heath Properties (PHP) recently confirmed that yields had stabilised and there was strong demand in its sector. Questor says buy. Primary Health Properties 329p -6 Questor says BUY The company, which owns modern GP surgeries and pharmacies around the UK on long leases, said that rent increases on leases reviewed in its third quarter were...
PR Newswire With Zend, Businesses Benefit from Cloud Economics While Enjoying Out-of-the-box Scalable and Manageable PHP with Freedom to Leverage Cloud Infrastructure and Services of Choice Download image...
PR Newswire Zend Studio 8.0 Streamlines PHP Application Development in VMware Virtualized Environments and Features Enhanced Support for Building Ajax and PHP Applications Download image...
Yahoo Daily NewsAmazonWeb Services (AWS) has released a toolkit to make it easier to develop applications in PHP that will run on Amazon's cloud, the company said on Wednesday. Using the AWS SDK for PHP, which works with PHP 5.2 or later versions, developers can build applications that use different parts of Amazon's cloud, including...
PR Newswire Customers Can Run Zend Server and Zend Server Cluster Manager on SUSE Linux Enterprise Servers, and Ease Troubleshooting of PHP Applications in On-Premise and Cloud Deployments Download image...
GroundReportAn article by Chris Jones on Oracle.com talks about how php developers can use Oracle Database’s client identifier in PHP applications. The client identifier in OCI8 PHP-to-Oracle can assist with connections for auditing, monitoring Oracle database and profiling....
The Daily TelegraphPrimary HealthProperties 295p Questor says BUY HEATHCARE property investor Primary Heath Properties (PHP) managed to raise its rental income more than expected in the first half - and the group hopes to benefit from coalition government changes to the healthcare sector. PHP is one of the largest providers of primary healthcare properties in the UK. It builds and owns GP...