Loops & program structure of PHP scripts

Building Blocks of PHP PHP has some basic programming structure for developing scripts. There is conditional checking to evaluate true of false of a condition, there are loops with conditions and counters and we can check different variables by using simple functions. We can keep a commonly used code blocks inside a function and then call and use them when ever required. All these are basic building blocks of developing a PHP application.

As PHP has more similarity with C language so it has similar for, while, do loops and other functions.

We will learn how this basic flow of PHP language works with example in every section.

if else : Conditional checking with if else

We can check condition of any variable or any data by using if condition. This if condition checks TRUE or FALSE and accordingly it allows the blocks to execute.

for Loop

We can loop through a set of code by keeping them inside a for each loop. We can specify the jump in increment or decrement of counter in each looping.

While loop

Here before executing the code inside the loop the condition is checked first. If the condition is TRUE or satisfied then the code inside the loop is executed.

Do while loop

What is the difference between while loop and do while loop? Which one to use in what conditions, when the condition is checked for executing the code inside loop ?

Switch statement

When we know one of the choice of a option is going to match and rest of the options are not going to match once a options is meet then we should go for switch statement then repeated use of if else conditions.

Questions


PHP

Subscribe to our YouTube Channel here


Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com







    Post your comments , suggestion , error , requirements etc here





    PHP video Tutorials
    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2024 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer