Learning PHP with Programming Exercises

Ranked #864 in Internet, #44,263 overall

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.

Beginner PHP Books

Loading

PHP Exercises

This is when a site like phpexercises.com 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

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

Try It Yourself

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

HTML Books

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

Loading

Sites and Pages Referenced in this Lens

PHP Exercises
PHP exercises for beginning to intermediate programmers. Includes variables, operators, control structures, forms, arrays, functions.
PHP Control Structures Exercise #4: Nested For Loops
In this PHP exercise, the programmer uses nested for loops to create an HTML table of multiplication tables.

Your suggestions, comments, experiences learning PHP

  • NAbdelMegeed Feb 19, 2012 @ 6:52 am | delete
    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
  • ThePresentMoment Feb 8, 2012 @ 6:43 am | delete
    Some good PHP resources here bud! Check out my lens How To Create a Website
  • Aug 12, 2011 @ 7:54 am | delete
    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.
  • bambytop Aug 7, 2011 @ 12:09 am | delete
    i'm using this execises to my students
  • nagiracbe Jun 15, 2011 @ 11:45 pm | delete
    Nice examples. Thanks for making it avail to public. ASP.NET Hosting

by

pixilian

Helping to spread the word about PHP, one <? at a time.

Feeling creative? Create a Lens!