30 April 2006

PHP Variables

Using Php Variables
Php Variables are are used for storing values, such as strings, numbers। Once stored they can be called from anywhere within the script।

Note :Variables can not have spaces and only contain alpha-numeric characters and underscores.
$myVar or $my_Var both is correct.



Output of this script is :
Hi Friend

Below is another example :


Output of is :
2 + 2 is 4

10 May 2005

PHP Switch Statement

Php Switch statement is very useful, it works like if/else statement & reduce the complication of numerous conditions in the script.

Syntax :

switch (expression)
{
case 1
code .. //execute code if expression = 1
break;
case 2
code ... //execute code if expression = 2
break;
default:
code...//execute code if expression not matched
}
Example :


<?php

$value = 6;

switch ($value)

{

case 1:

echo "Value 1";

break;

case 2:

echo "Value 2";

break;

case 3:

echo "Value 3";

break;

default:

echo "Value is " . $value . " not matched!";

}

?>