Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


Getting my head around concepts such as loops, if, else if, etc, using PHP but mainly CraftCMS and Twig

I need to get my head around the concepts of oops, if, else if, etc. I have been doing some tutorials on here with PHP but I really need it dumming down because all I am doing is copying and pasting and really not understanding what I am doing.

I need to ask questions like - what is a loop? what is an if statement? what is and elseif if . . . .

I am a bit of a slow learner but if I can get my head around these things I think I can make progress.

Can anyone suggest a course on here or something to read?

I am mainly using CraftCMS and Twig templating, but will need to apply his knowledge to Wordpress.

nico dev
nico dev
20,364 Points

Hi Steve Davies ,

Well, first of all, don't worry too much about it, it's pretty normal to feel like that, after some time you get used to it :) I know exactly how you feel, because I was in that exact position of not fully understanding loops, conditionals, and other stuff a short while ago, and now that I more or less got the hang of them, I am still in that position, but just with other things |o|. Really, with just enough determination, you get used to it.

Having said that, I know JavaScript does not seem to be where you're heading, but the guy that made that things crystal clear to me was Dave McFarland in this and then this course. If you want, you can watch them, pay close attention, and try to get mostly the concepts explained. These courses have the perfect dosage of 'building one concept on top of the other' that I bet you after finishing those 2, you'll face anything else with confidence!

Disclaimer: Don't blame me if you fall in love with JavaScript...that could never have been my intention. :)

Another tip from my own experience/struggles: when you are learning say loops, try to think of a little problem you might be able to solve with them, and then test your persistence trying to do it by yourself with what you're learning. You will feel frustration, but with persistence you'll get the hang of it. Promise!

Hope that helps. Keep it up!

2 Answers

Patrik Horváth
Patrik Horváth
11,110 Points

PHP basics or Java Basics or JavaScript Basics or C# Basics .....

every language have almost same syntag in IF and LOOPs so start where you want :)

your other questions like Whot is loop ? - type in google and you find answere i m 100% sure or just watch any Programing language basics and they always describe it :)

Thanks, I appreciate your answer, but struggling to find something that explains it to a dummy. I know it will be one of those things that will just click when I get it. When I was learning CSS the same thing happened, someone described it a certain way and I got it.

Patrik Horváth
Patrik Horváth
11,110 Points

so then i recommended Book for Java for example :) in books its described a lot better then in videos ( i strated with Java 8 for Begginers by Herberth Schildt takes me about 1 mounth to done this book then i strated with PHP, JS and everything seems same)

example For Loop as you can see every language is almost same

for (DEFINE BEGGINING VARIABLE AND SET IT TO START POINT,  RULE - < or > or = or combination; Increment or Decrement ) {
whot should your program do every time


for (int i = 0; i < 5; i++) { }
if (a > b) { }


for ($i = 0; i < 5; i++) { }
if ($a > $b) { }


for(let i = 0; i < 5; i++) { }
if (a > b) { }


Thanks everyone for all your input!