In a nutshell, PHP is a popular scripting and programming language. PHP is used to build dynamic web pages on the fly by pulling information from a database. PHP is arguably the most popular scripting language that is used to build dynamic websites, web applications and web services.
Why is PHP so popular?
- Free and Open Source
- Cross Platform – Works on every operating system, platform, and most web servers
- Huge support community
- Continuously updated and improved
- Easy to get started and learn (http://www.easyphp.org/ and www.php.net)
Let’s put PHP into context
- PHP works with HTML and databases like MySQL to build webpages, or entire websites, on the fly
- Java, Perl, Python and Ruby are alternatives to PHP
- PHP is the backbone of the most popular website creation tool and content management system of all time – WordPress
What is PHP used for?
A more useful question might be “What isn’t PHP used for?” Basically, you can use PHP to build almost any kind of interactive web content:
- Username and password login pages
- Picture galleries
- Polls and surveys
- Web applications
PHP and HTML in Action
PHP allows you to embed scripts into the HTML code of a webpage. When the webpage gets loaded into the browser, the server executes the PHP script and then sends the code to the browser as standard HTML. When you view the source code of a PHP webpage, you will only see the HTML code that is created on the fly when the server interprets the PHP code and tells the browser how to display the page.
Here’s a tiny example of how the code looks if you want to dynamically add today’s date into an HTML paragraph:
<p>The date today is <?php echo date('l, F dS Y.'); ?></p>
When the web page gets loaded into the browser, the “View Source” output will look like this:
<p>The date today is November 30, 2011</p>
Added Bonus with PHP: Prettier URLs
The URL of web pages created with PHP do not have that ugly file type suffix that web pages created with HTML alone have. For example, before PHP our jobs page URL looked like this: www.stafflink.ca/joblist.htm. Now that we use PHP the URL for our jobs page is www.stafflink.ca/jobs. The “.htm” is no longer needed.
Will PHP help you get a job?
PHP alone will not get you very far. But it’s a great skill to add to your toolbox. It’s not very often that we get a job for a PHP programmer. However, our clients usually include PHP in the laundry list of skills that they are looking for when they are hiring a programmer or web developer.