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:
- Blogging software such as WordPress
- E-commerce systems like Magento
- Content management systems including Drupal and Joomla!, and
- Forum software such as phpBB.
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:
- Perl (read our Perl articles)
- ASP and its successor, ASP.NET (read our ASP articles)
- Python
- Ruby, and
- Java.
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!
Leave a Reply