Have you ever gone to a website and after you have logged in, it shows you your sign up name, right there on the screen? Or it shows today’s date, or today’s cinema listings? These are all examples of “dynamic” elements on a website - they are generated and presented to you when you visit the website. With PHP, you can do all this and much, much more - and we’ll show you how!
PHP is designed to be easy to jump into and get up and running, but its also immensely powerful as your knowledge and skill increases. While it is recommended that you have at least some prior HTML experience, if you have patience and a desire to learn something new, PHP is one of the easier languages to pick up.
Items required before getting started
So what do you need to start PHP programming? Well, just three things really:
- A website host that supports PHP. Most hosts do, but sometimes PHP support needs to be “switched on” in your hosting control panel. If you are not sure if your host supports PHP, contact them and ask!
- An FTP client, which will allow you to upload your PHP files to your website host - I recommend FileZilla (http://filezilla.sourceforge.net/)
- A good text editor - I recommend EditPlus2 (http://www.editplus.com/download.html)
With all these three in hand, you are ready to begin coding!
Part 1 - Hello World
Open up EditPlus and create a new file - EditPlus is a good editor, as it comes with templates for PHP. This means it will colour-code recognised PHP keywords, making it easier to keep track of your code. When you first open EditPlus, go to File->New->Others. Select “PHP” and click OK.
Then, copy paste the following into the blank document you just created:
<?php
echo 'Hello World, the time is now ' . date('D., F jS Y H:i:s');
?>
Save the file as “part1.php”, and upload it to your website host. Then in your Internet browser, go to your website host and try to view the file. You should see the following on your screen:
Hello World, the time is now Tue., December 12th 2006 14:36:28
…where the date displayed should be today’s date instead! If it didn’t work, check that you have used the correct filename (the .php extension is important!). Also, make sure you are looking at the correct location on your web host.
This first example shows you how PHP can generate today’s date and present it in a web browser. If you hit Refresh on your browser, you will see that the time will update too. This is because PHP is a “server-side” technology - when someone requests the web page “part1.php”, the website host “runs” the PHP file, and sends the result to your web browser as a standard HTML webpage.
Having any difficulty running this? Leave a comment here and I’ll do my best to help you out!
Click here to view the next installment (part 2), we will look at a slightly more sophisticated example of PHP’s power.





March 25th, 2007 at 3:50 pm
[...] Upload both files to the same directory on your webhost, and then go to yourwebhost.com/part2a.php. Click here to see Part 1 of the PHP Tutorial series… Share and Enjoy:These icons link to social bookmarking sites where readers can share and discover [...]
July 20th, 2007 at 4:40 pm
[...] Beginners Guide to PHP - Part 2: POSTing information [...]