+ All Categories
Home > Technology > Introduction to php 5

Introduction to php 5

Date post: 18-Aug-2015
Category:
Upload: pctechnology
View: 21 times
Download: 1 times
Share this document with a friend
Popular Tags:
12
Transcript

PHP Operators› Arithmetic operators› Assignment operators› Comparison operators› Increment/Decrement operators

PHP Conditional Statements› if statement› if...else statement › if...elseif....else statement › switch statement

Logical operators String operators Array operators

Loop Functions› For Loop› While Loop› Do While

Functions Arrays Manipulate Arrays Variable Scope

The while loop executes a particular set of codes till the condition is true

Syntax :

while (condition is true)

{    code to be executed;}

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);

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;}

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

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

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.

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

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>";

}

To make a function return a value, use the return statement

Declaration :

<?phpfunction sum($x, $y) { $z = $x + $y; return $z;}


Recommended