ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel

Learning PHP with Programming Exercises

Updated on December 5, 2010

PHP Is Everywhere

You know about PHP, how it's taking over the Web, found on over 20 million domains. You've probably already started to learn the language, either through online tutorials, classes, or books. Or a combination. Now you want to practice your skills, try your hand at writing some scripts on your own.

Beginning to Write Your Own Scripts

When you create your first scripts, it's nice to have some direction. If you are taking a class, that's not a problem. But if you are using online tutorials or books, finding direction can be difficult. If you try to create something from scratch and run into a problem, you can get frustrated trying to figure out what isn't working right. What you need are programming exercises. Exercises for PHP can be really hard to find on the Web. The few that do exist usually don't provide the answer script, much less the output from the script.

Books are great and usually do include some programming exercises with answer scripts. But in the hectic editing process, some scripts end up with errors. Once again, you can be stuck not knowing what went wrong.

PHP Exercises

This is when a site like can give you a big boost, help you write scripts and gain confidence. Exercises start at the very beginning, with simple text printed to the browser, and go from there. If you have spent any time with PHP, you should be able to find an exercise suited to your level of proficiency. Included are variables, loops, conditional statements, forms, arrays and functions.

In the screen shot below is an example exercise. To use the exercise, you follow the instructions, writing and testing the script on your own computer. When you have it functioning properly, you click the 'View Script' button (circled in red) back on the exercise page.

Example PHP Exercise: Nested For Loops
Example PHP Exercise: Nested For Loops

Seeing the Answer Script and Output

When you click the button, you see the script, as in the image below. Comments in green explain some of the workings of the script. If you follow the link at the bottom (circled in red), you can bring up the output from the answer script. This shows you that the script has been tested and works, and might help you troubleshoot your own.

Script for Nested For Loops Exercise
Script for Nested For Loops Exercise

Try It Yourself

If you are a beginning to intermediate PHP programmer, visit and test your skills.

HTML Books - The more HTML you know, the better for programming with PHP.

Your suggestions, comments, experiences learning PHP

    0 of 8192 characters used
    Post Comment

    • szemi lm profile image

      szemi lm 5 years ago

      Thanks for the info about php exercises! It's more efficient for me with these exercises to learn PHP

    • profile image

      andrusiamand64 5 years ago

      PHP is one of the most used scripting language in development. PHP is used a lot on online shopping websites. I like PHP web development language very much.

      Php web development

    • Binarydog LM profile image

      Binarydog LM 5 years ago

      Great lens, PHP is a fantasic language.

    • profile image

      anonymous 5 years ago

      nice lens good work

    • profile image

      webguru_india 5 years ago

      You have penned a great article,it seems good. Its really helpful to everyone..Check out my recent work too

    • profile image

      samjames700 5 years ago

      You have done a great job,it seems good.These blogs are giving out for sure a lot of useful tips.Its really helpful to everyone..Check out my recent work : web development company

    • profile image

      anonymous 6 years ago

      Hi there! thanks for this wonderful lens. There's a lot of useful information about php here. It's a good place for beginners. PHP is getting popular more and more each day. A lot of people in the IT business recommend using PHP because of lots of reasons. Of course the most important reason is that it's open source and free. Thanks again for this lens and keep up the good work

    • profile image

      ThePresentMoment 6 years ago

      Some good PHP resources here bud! Check out my lens How To Create a Website

    • profile image

      anonymous 6 years ago

      Hello the post is really informative one i was searching for this to gain knowledge. thanks a lot for sharing this with us. For more informationCustom Software and Web Development.

    • profile image

      bambytop 6 years ago

      i'm using this execises to my students

    • profile image

      nagiracbe 6 years ago

      Nice examples. Thanks for making it avail to public. ASP.NET Hosting