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

PHP

PHP elseif

Does anyone have a flow chart that shows a the flow of an elseif statement please?

5 Answers

Since PHP is an interpreted language the code is processed from top to bottom as it is executed. So if you have an example:

 if ($x == "something) {
    // do something
} elseif ($x == "something else") {
    // do something different
} else {
   // catch all match
}

As the code is executed to will evaluate against the first "if", then the "elseif", and if nothing matches it falls into the "else" category.

Does this help?

HI Damian it does kind of but I was after a flow chart of the process.

Just so I can get my slow brain around in fully.

G

Matt West
Matt West
14,545 Points

Hi Graham,

Whipped up a quick flow chart for you.

http://f.cl.ly/items/3t0b342M460w1Q2r3p2b/PHP%20elseif%20Flowchart.png

I hope this helps :)

Hi Matt

Total legend thanks for that - makes perfect sense and I can add it to my other reference material

Cheers Fella

G

Matt West
Matt West
14,545 Points

No worries.

Glad it helped :)