SQL PHP HTML ASP JavaScript articles and free scripts to download
 

Loops & program structure of PHP scripts

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.

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. Read More

Loop using for each
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. Read More

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. Read More

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 ? Read More

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. Read More

How to check the presence of a variable
PHP function isset is used to check the existence of a variable before using it. This is required in different conditions where processing the script by a non existence variable can create problem. Read More

Discuss this tutorial at forum


Further readings
Loops and program structure of PHP scripts
Checking variables by isset
switch
For Loop
if else condition checking
while loop
Do while loop
PHP beginners guide

 

Subscribe
Submit your email address and receive article and product notifications. Your email is safe with us.

Scripts
PHP
JavaScript
PHP Tutorials
Basic Loops
PHP Sections
PHP Introduction
Loops & structure
Array
Date & Time
Functions
Form Handling
File Handling
Math Functions
String Functions
GD Functions
Comment Posting
Content Management
PHP & Ajax
Popular Tutorials
Drop down list
File Upload
Signup script
Member Login
Line Graph
PHP MySQL Paging
PHP Calendar
Subscribe
Submit your email address and receive article and product notifications. Your email is safe with us.