What is PHP?
PHP is an open source software script that stands for Hypertext Preprocessor. It is free to download and use. PHP is mainly focused on server-side scripting and allows the ability to collect form data, generate dynamic page content, or send and receive cookies. Its code is executed on the server, and the plain HTML result is sent to the browser.
Who developed PHP & Why?
PHP was developed in 1994 by the Danish/Greenlandic programmer Rasmus Lerdorf. Initially, it created a set of Perl scripts he called ‘Personal Home Page Tools’ to maintain his personal homepage and it included tasks like displaying his resume and recording how much traffic his page was receiving.
PHP Creator Rasmus Lerdorf
In 1997 two developers at the Technion IIT, Zeev Suraski and Andi Gutmans, rewrote the parser and formed the base of PHP 3, changing the language’s name to PHP: Hypertext Preprocessor. Public testing of PHP 3 began, and it was officially launched in June 1998. Suraski and Gutmans then started a new rewrite of PHP’s core, producing the Zend Engine in 1999. They also founded Zend Technologies in Ramat Gan, Israel.
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.
How do you use PHP?
PHP pages contain HTML with embedded code. The PHP code is enclosed in special start and end processing instructions <? php and ?> that allow you to jump into and out of “PHP mode.” It’s scripting block can be placed anywhere in the document. One of the best features in using PHP is that it is both extremely simple for a newcomer and offers many advanced features for a professional programmer.
A PHP file normally contains HTML tags, just like an HTML file, and some PHP scripting code. Each code line in PHP must end with a semicolon. The semicolon is a separator and is used to distinguish one set of instructions from another.
Additionally, the file must have a .php extension. If the file has a .html extension, the PHP code will not be executed. There are two basic statements to output text with PHP: echo and print. Print and Echo both output data to the screen in a similar fashion, but differ in how they are structured. Most developers use Echo, but either can be used effectively.
The 3 main areas where PHP scripts are used:
- Server-side scripting. This is the most traditional and main target field for PHP. You need three things to make this work. The PHP parser (CGI or server module), a web server and a web browser. You need to run the web server, with a connected PHP installation. You can access the PHP program output with a web browser, viewing the PHP page through the server. All these can run on your home machine if you are just experimenting with PHP programming. See the installation instructions section for more information.
- Command line scripting. You can make a PHP script to run it without any server or browser. You only need the PHP parser to use it this way. This type of usage is ideal for scripts regularly executed using cron (on *nix or Linux) or Task Scheduler (on Windows). These scripts can also be used for simple text processing tasks. See the section about Command line usage of PHP for more information.
- Writing desktop applications. PHP is probably not the very best language to create a desktop application with a graphical user interface, but if you understand PHP well, and feel comfortable using advanced PHP features in your client-side applications you can also use PHP-GTK to write such programs. You also have the ability to write cross-platform applications this way. PHP-GTK is an extension to PHP, not available in the main distribution.
Compatibility & Support
PHP gives the author the freedom of choosing an operating system and a web server, including Linux, many Unix variants (including HP-UX, Solaris and OpenBSD), Microsoft Windows, Mac OS X, RISC OS, and probably others. It also can support most of the web servers including Apache, IIS, and many others. PHP works as either a module, or as a CGI processor.
PHP’s abilities are not just limited to outputting HTML, it can also output images, PDF files and even Flash movies (using libswf and Ming). You can also output easily any text, such as XHTML and any other XML file. PHP can autogenerate these files, and save them in the file system, instead of printing it out, forming a server-side cache for your dynamic content.
Related Technologies
One of the strongest and most significant features in PHP is its support for a wide range of databases. Writing a database-enabled web page is made very simple by using one of the database specific extensions (e.g., for mysql), or using an abstraction layer like PDO, or connect to any database supporting the Open Database Connection standard via the ODBC extension.
PHP also has support for talking to other services using protocols such as LDAP, IMAP, SNMP, NNTP, POP3, HTTP, COM (on Windows) and many others. PHP has support for the WDDX complex data exchange between virtually all Web programming languages. Additionally, PHP has support for instantiation of Java objects and using them transparently as PHP objects.
PHP has useful text processing features, which includes the Perl compatible regular expressions (PCRE), and many extensions and tools to parse and access XML documents. PHP standardizes all of the XML extensions on the solid base of libxml2, and extends the feature set adding SimpleXML, XMLReader and XMLWriter support.
Additional Resources:
A helpful tutorial for beginners to learn the basics of PHP programming
PHP: Hypertext Processor
Works Cited: