PHP is a relatively easy language to learn if you are familiar with HTML/CSS. Here, and following, are the presentations to familiarize yourself with PHP/MySQL and HTML Basics.
3. Loop Functions
› For Loop
› While Loop
› Do While
Functions
Arrays
Manipulate Arrays
Variable Scope
4. The while loop executes a particular set
of codes till the condition is true
Syntax :
while (condition is true)
{
code to be executed;
}
5. The do-while loop execute the block of
code once, and then checks the
condition and repeats the loop, while
the specified condition is true.
Syntax :
do
{
code to be executed;
} while (condition is true);
6. It is used when we already know the
number of times we want to run that
loop.
Syntax :
for (init counter; test counter; increment counter)
{
code to be executed;
}
7. While loop checks for the condition first.
so it may not even enter into the loop, if
the condition is false.
do while loop, execute the statements in
the loop first before checks for the
condition. At least one iteration takes
places, even if the condition is false.
for loop is similar to while loop except
that initialization statement, usually the
counter variable initialization
8. The main power of PHP is in its Functions,
user defined functions or system
functions
PHP has many inbuilt functions.
User can also define functions
A function is a set of statements that can
be used repeatedly in a program
Function will be executed by the call to
the function
9. A user defined function should start with
a “function” tag
Syntax :
function functionName() {
code to be executed;
}
A function name can start with a letter or
underscore but not a number.
Function names are NOT case-sensitive.
10. Some functions require inputs to work
properly, eg. Area, conversions, etc.
Arguments are specified after the
function name, inside the parentheses
An Argument behaves as a variable
here, it is used to pass the value
11. If a default value needs to be set, we will
specify it in the arguments to the
function
Declaration :
<?php
function functionname (arguments = value) {
echo "The value is : $minlimit <br>";
}
12. To make a function return a value, use
the return statement
Declaration :
<?php
function sum($x, $y) {
$z = $x + $y;
return $z;
}