What is PHP?

What is PHP, and what can you do with it? This gentle PHP introduction explains the basics of PHP and looks at how you can use it to build feature-rich Web pages and applications.

What is PHP? PHP is a programming language that you can use to write Web applications. A Web application can be anything from a simple "contact us" form through to a fully-fledged blogging system, online store, or forum system.

PHP is a server-side language

PHP is known as a server-side programming language. This means that it runs on the Web server. Most Web programming languages are server-side, but some, such as JavaScript, are client-side, which means they run on the Web browser.

Server-side languages give you more flexibility as they can do many things that are hard to do with JavaScript — for example, working with files and databases, or manipulating images. That said, JavaScript is coming along in leaps and bounds these days (as these examples show).

Server-side code is also potentially more secure than JavaScript code. Since JavaScript code is sent to the Web browser it's easy for a visitor to view and edit the code. Server-side code, on the other hand, remains on the Web server and isn't accessible to visitors to the site.

PHP is open source

The PHP engine — that is, the code that sits on the Web server and runs PHP scripts — is open source, which means anyone can access and work on the engine's source code. This helps to ensure that PHP will be around for a long time to come.

PHP is free to download and use, which is one reason why it is so popular among Web hosting companies. You'll find that the vast majority of Web hosting accounts support PHP.

PHP is geared towards the Web

While many programming languages can be used to build Web applications, PHP is one of the few languages specifically designed for the Web. To this end, it includes a lot of useful Web-related features out of the box, such as:

  • Easy ways to read and handle Web forms and cookies
  • Functions for creating and manipulating graphics
  • The ability to talk to popular databases such as MySQL, and
  • Functions for working with HTML.

You can mix PHP code with HTML code

One nice feature of PHP is that you can insert chunks of PHP code into an HTML page. You surround the PHP chunks with special symbols. When the Web server retrieves the page, any PHP chunks are run by the PHP engine, while the other parts of the page are sent as they are to the browser.

This feature makes it easy to add interactivity to otherwise plain Web pages — great for contact forms and the like.

Uses of PHP

You can use PHP to write practically any type of Web application or script. Common PHP applications include:

In addition, many popular websites, including Yahoo!, Wikipedia, Facebook, and Digg, use PHP code extensively.

Alternatives to PHP

If you don't fancy using PHP then there are many similar languages available. Some common server-side languages include:

Learn more about PHP

To get started with writing PHP scripts, try the Writing your first PHP script tutorial.

The PHP website is a great place to learn more about PHP. You'll find an introductory tutorial and a complete online manual.

Happy coding!

Learn PHP With Ease!

Written by Matt Doyle — ELATED's resident Web programming expert — Beginning PHP 5.3 is a complete introduction to PHP, covering everything in these tutorials and lots more besides. Find out how to:

  • Set up PHP on your computer
  • Use strings, arrays, functions and objects
  • Create interactive Web forms
  • Handle cookies and sessions
  • Work with files on the server
  • Build database-driven sites with MySQL
  • Send emails from your scripts
  • Create images on the fly with PHP
  • Work with regular expressions
  • Write robust, secure PHP applications

...and lots more!

“What a pleasure it's been spending hours and hours studying PHP with this magical book.” — Lulio, Florida
“The book is not only great for learning, but I find myself using it constantly as a reference as well!” — David A. Stoltz

Buy Beginning PHP 5.3 now from Amazon.comBeginning PHP 5.3 or Amazon.co.ukBeginning PHP 5.3.

Follow Elated

Related articles

Responses to this article

There are no responses yet.

Post a response

Want to add a comment, or ask a question about this article? Post a response.

To post responses you need to be a member. Not a member yet? Signing up is free, easy and only takes a minute. Sign up now.

Top of Page