PHP Tutorial – foreach Loop

The “foreach” loop gives PHP an easy way to iterate over arrays and can only be used on arrays.

Syntax

There are two syntaxes although the second is only a minor extension of the first. More »


Posted in PHP Tutorials | 2 Comments


PHP Tutorial – For Loops

The “for loop” execute a block of code a specified number of times while a specified condition is true.

Syntax


for (init; condition; increment)
{
    code to be executed;
}

More »


Posted in PHP Tutorials | 3 Comments


PHP Tutorial – do…while Loops

The do…while statement will always execute the block of code once. After this first execute it will check the condition, and repeat the loop (keep executing) while the condition is true. More »


Posted in PHP Tutorials | Comments Off on PHP Tutorial – do…while Loops


PHP Tutorial – While Loops

The PHP language has four different kinds of conditioned loops. In this PHP tutorial we will look at the “while” loop. Loops are used to execute a block of code multiple times.

In PHP, we have the following loop statements: More »


Posted in PHP Tutorials | Comments Off on PHP Tutorial – While Loops


PHP Tutorial – Arrays

In this PHP language tutorial we will take a look at arrays in PHP. A normal variable holds only one value. An array is different. An array lets you declare and work with a collection of values.

If you would use normal variables to store for instance a list of names it would look something like this: More »


Posted in PHP Tutorials | 2 Comments


PHP Tutorial – If else Statements

In this PHP programming tutorial we will take a look at the “if else statement” (the PHP “switch statement“ can be found here.) Conditional statements (such as “if else” or “switch”) are used to alter the flow of a program if a specific test condition is true. More »


Posted in PHP Tutorials | 4 Comments


PHP Tutorial – Switch Statement

Just as the PHP language “if…else” statement, you can use the “switch” statement to alter the flow of a program. In other words; conditional statements are used to perform actions on different conditions. The switch statement is used to select one of many blocks of code to be executed. More »


Posted in PHP Tutorials | Comments Off on PHP Tutorial – Switch Statement


PHP Tutorial – Operators

In this PHP programming tutorial we will look at PHP operators. An operator is something that can be used to do operations on values to get a new value. We will look at: Arithmetic, Assignment, Logical, Comparison and Concatenation (string) Operators. More »


Posted in PHP Tutorials | Comments Off on PHP Tutorial – Operators


PHP Tutorial – String Variables

In this PHP programming tutorial we will look at common string functions. String variables are used to store and manipulate text.

In the PHP script below we assign the text “Hello everybody” to a string variable $my_string and print the content of the variable: More »


Posted in PHP Tutorials | 1 Comment


PHP Tutorial – Variables

In this PHP programming language tutorial we will look at variables. A variable is used to store information or values in, like text-strings, numbers or arrays. As long as you don’t remove the value in a variable then you can use the variable (thus the value) over and over again. More »


Posted in PHP Tutorials | 3 Comments