Loops in PHP

FOR Loop:

A FOR loop continues to process a block of code until a statement becomes false, and everything is defined in a single line, making it somewhat different to a WHILE loop. Read about FOR Loops

WHILE Loops:

Basically what a WHILE loop does is evaluate a statement as true or false. If it is true it executes some code and then alters the original statement and starts all over again by re-evaluating it. It continues to loop through the code like this until the statement becomes false

Examples :

for loop

for_loop

while loop

while_loop

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s