PHP 5 for Loops

PHP 5 for Loops

PHP for loops execute a block of code a specified number of times. The PHP for Loop The for loop is used when you know in advance how many times the script should run. Syntax for (init counter; test counter; increment counter) {   code to be executed; } Parameters:...
PHP 5 while Loops

PHP 5 while Loops

PHP while loops execute a block of code while the specified condition is true. PHP Loops Often when you write code, you want the same block of code to run over and over again in a row. Instead of adding several almost equal code-lines in a script, we can use loops to...
PHP 5 switch Statement

PHP 5 switch Statement

The switch statement is used to perform different actions based on different conditions. The PHP switch Statement Use the switch statement to select one of many blocks of code to be executed. Syntax switch (n) { case label1:       code to be executed if n=label1;...
PHP 5 if…else…elseif Statements

PHP 5 if…else…elseif Statements

Conditional statements are used to perform different actions based on different conditions. PHP Conditional Statements Very often when you write code, you want to perform different actions for different conditions. You can use conditional statements in your code to do...
PHP 5 Constants

PHP 5 Constants

Constants are like variables except that once they are defined they cannot be changed or undefined. PHP Constants A constant is an identifier (name) for a simple value. The value cannot be changed during the script. A valid constant name starts with a letter or...
PHP 5 Strings

PHP 5 Strings

A string is a sequence of characters, like “Hello world!”. PHP String Functions In this chapter we will look at some commonly used functions to manipulate strings. Get The Length of a String The PHP strlen() function returns the length of a string. The...