Beginner PHP Exercises

Soldato
Joined
15 Nov 2007
Posts
13,176
Location
Hertfordshire
I've started learning PHP and very slowly getting to grips with things. Problem is, whilst there are a lot of tutorials out there what I want to do is get stuck in and solve some actual problems. I found this page really useful as it allowed me to do practical things with the code instead of just reading how it works.

There are a lot of tutorials but very few actual exercises it seems - I need some really basic stuff to get my teeth into. Does anyone have any recommendations? I've been looking at if else loops and for loops, that kind of thing.

Cheers :)
 
I think the best thing to do is to think up some kind of system in your head... and then attempt to make it. Popular ones might be - creating a blog system (doesn't need to be as complicated as wordpress), a 'membership' area (use of sessions etc), or even some kind of a rudimentary forum/message board. :)
 
I think the best thing to do is to think up some kind of system in your head... and then attempt to make it. Popular ones might be - creating a blog system (doesn't need to be as complicated as wordpress), a 'membership' area (use of sessions etc), or even some kind of a rudimentary forum/message board. :)

+1

Try creating a CMS system with an admin only area , a membership area, comment system and then perhaps an image uploader with built it re-scaling & water-marking.

Lots of support on the internet for these as well :)

Edit : Assuming you're , or plan on learning MYSQL too :p
 
Last edited:
Hmmm, thanks for your thoughts but I think that's a weeeee bit over my skill level. I'm a total n00b with this...I was overjoyed on Friday when I managed to make a do-while loop that printed 012345, lol :D
 
If you are still at that stage then you might be best off just learning all of the basics and not really worrying about how you apply them to a solution at this stage.

If you want to see something tangible with relevence then just think of a little real world problem that uses the algorithm you have created. Its a good exercise either way. Once you are comfortable with that and all the other basics of PHP then try to integrate them all into a site. Doesnt have to mean anything but its good practice to get the flow of website programming. Take it easy and good luck.
 
mot programmers have their own favourite 'little dittys' that they do whenever they are learning a new language.

I have often programmed the 'guess the number game' when messing about with different languages.

rough pseudo code:

1. get user1 to enter number (or have the computer randomly generate a number)
2. Then ask user2 to guess the number
3. if number bigger, print too big
4. if number smaller print too small
5. if number right - print great job
6. go to 1
 
Hmmm, thanks for your thoughts but I think that's a weeeee bit over my skill level. I'm a total n00b with this...I was overjoyed on Friday when I managed to make a do-while loop that printed 012345, lol :D

Would recommend a book called 'PHP Cookbook' - first quarter of the book covers all the basics in a very concise and to the point way, rest of book covers more involved stuff.
 
Thanks for all the advice guys - will definitely check out all your thoughts/links. Very helpful :)
 
make a page counter. that reads the current hits from a textfile, adds 1, and shows the hits.

you will also learn a little about the system you are working on (presumably linux?, on the server) because you will need to change the file permissions.

functions you may need:
fopen
fread
fwrite
and
fclose

those are the general 4, but of course it could be done with file_get_contents and file_put_contents
 
Last edited:
Back
Top Bottom