February 5th 2007
(3) PHP Lesson 1
Educational, Programming, Tutorials
I’m going to start producing a few classes for those people who wish to start learning the wonderful programming language of PHP. These will be pretty simple classes and will reach until the end of my knowledge of the language. First, a bit of my experience - albeit a relatively short one.
My History
I first started to learn PHP 3 years ago and have since then done some things I’m quite proud of in the language. I’ve built a system for a hospital in Reading, my own blogging software (although quite simple, it does the job) and also a file directory viewer with AJAX technology. But, my PHP knowledge is quite limited and I have not used the language now for some times as I have been concentrating on the design aspect of the web.
Lesson 1: Hello World!
Every programmer starts off with the ‘Hello World!’ program. Here we are going to get PHP to output the text ‘Hello World!’ to the screen. From this point out I’ll assume you’ve installed PHP and have it running on Apache or the like.
So, as with any PHP script we have to tell the server it’s going to be dealing with PHP. So we start it off with the opening and closing tags. All code goes between these tags:
<?php
?>
Now, as I said all PHP code goes in between these tags. So, now we have to make it do what we want it to do. So, in between those tags we know insert this line of code which tells it to output the text to the screen:
echo "Hello World!";
Once we’ve put this all together we should be able to achieve the result we wanted. Try it yourself on your own server! Just save the following code as a .php file and run it!
<?php
echo "Hello World!";
?>
It’s going to get a bit more complicated than this, I can assure you. I’ll post a lesson every weekday - every Friday we’ll do a roundup of everything we’ve learnt!
/images/9r_leaf.png)
[…] a previous post I started you off on the basics of PHP and you managed to get Hello World! displayed on the screen. […]
[…] of my series of lessons on PHP. We are going to incorporate everything we have learnt in lessons one, two, three and […]
Sorry about asking this in a comment, but I couldn’t find a contact address for you.
I assume you mean the Royal Berks? If so, mind if I ask what system? I work there and you’ve got me curious.