echo 'waqas</br>';
//variables
$txt = '<b>waqas khan</b>';
$numb = 134;
echo $txt.' '.'<u>'.$numb .'</u></br>';
//if/ if else ststment
$a = 2;
$b = 3;
//if statment
if ($a!=$b) {
echo 'true </br>';
}
//if else statment
$a1 = 3;
$b1 = 10;
if($b1<=$a1) {
echo 'true </br>';
} else {
echo 'false </br>';
}
//if/else if statment
$a2 = 8;
if($a2==10) {
echo 'equal to 10';
} else if ($a2==5) {
echo 'equal to 5';
} else {
echo 'not equal! </br>';
}
//assignment operetors
// -=, +=, %=, *=
$b2 = 5;
$b2 += 3;
echo $b2.'</br>';
$nam = '<b>hammad</b>';
$nam .= ' ali';
echo $nam.'</br>';
//comparision operators
// ==, >, <, >=, <=, !=, <>
if(1<>2) {
echo 'true </br>';
}
if(1!=2) {
echo 'true </br>';
}
//arithmetic operators
// +, -, *, /, %, ++, --
$sum = 3+4;
echo $sum.'</br>';
$a3 = 10;
$b3 = 2;
$c1 = 4;
$result = ($a3 - $b3) / $c1;
echo $result.'</br>';
$c2 = 4;
$c2++;
echo $c2.'</br>';
//logical operators
// &&, or, !,
$c3 = 5;
if ($c3>=4 && $c3<=4) {
echo 'true';
} else {
echo 'false </br>';
}
$a4 = 4;
if($a4==4 or $a4==3) {
echo 'true </br>';
} else {
echo 'false';
}
$b4 = 5;
if (!($b4==5) && ($b4==5)) {
echo 'true';
} else {
echo 'false </br>';
}
//triple equals
// ===,
$string = '1';
$integer = 1;
if($string===$integer) {
echo 'equal';
} else {
echo 'not equal </br>';
}
//while loop
$c4 = 1;
while ($c4<=10) {
echo $c4.' WAQAS</br>';
$c4++;
}
$a5 = 10;
while ($a5>=1) {
echo $a5.' KHAN</br>';
$a5--;
}
//do while loop
$b5 =1;
do {
echo ' Show';
$b5++;
} while ($b5<=3)
do {
echo 'Show</br>';
}
while (0)
// ==, >, <, >=, <=, !=, <>
if(1<>2) {
echo 'true </br>';
}
if(1!=2) {
echo 'true </br>';
}
//arithmetic operators
// +, -, *, /, %, ++, --
$sum = 3+4;
echo $sum.'</br>';
$a3 = 10;
$b3 = 2;
$c1 = 4;
$result = ($a3 - $b3) / $c1;
echo $result.'</br>';
$c2 = 4;
$c2++;
echo $c2.'</br>';
//logical operators
// &&, or, !,
$c3 = 5;
if ($c3>=4 && $c3<=4) {
echo 'true';
} else {
echo 'false </br>';
}
$a4 = 4;
if($a4==4 or $a4==3) {
echo 'true </br>';
} else {
echo 'false';
}
$b4 = 5;
if (!($b4==5) && ($b4==5)) {
echo 'true';
} else {
echo 'false </br>';
}
//triple equals
// ===,
$string = '1';
$integer = 1;
if($string===$integer) {
echo 'equal';
} else {
echo 'not equal </br>';
}
//while loop
$c4 = 1;
while ($c4<=10) {
echo $c4.' WAQAS</br>';
$c4++;
}
$a5 = 10;
while ($a5>=1) {
echo $a5.' KHAN</br>';
$a5--;
}
//do while loop
$b5 =1;
do {
echo ' Show';
$b5++;
} while ($b5<=3)
do {
echo 'Show</br>';
}
while (0)
//for loop
for($c5=10; $c5>=1; $c5--) {
echo $c5.' ';
}
for($a6=1; $a6<=10; $a6++) {
echo $a6.' ';
}
//switch statement
$b6 = 1;
switch($b6) {
case 1:
echo 'One</br>';
break;
case 2:
echo 'Two';
break;
case 3:
echo 'Three';
break;
default:
echo 'number not found</br>';
break;
}
//Another switch statement
$c5 = 'black';
switch($c5) {
case 'red':
case 'yellow':
case 'green':
echo 'Traffic ligth color</br>';
break;
default:
echo 'Not a traffic ligth color</br>';
break;
}
//Array $a7 = array('waqas', 'wahab', 'waleed'); $a7[3] = 'hammad'; print_r($a7); //echo $a7[1].'</br>'; //Associative array $b7 = array('waqas'=>26, 'wahab'=>18, 'waleed'=>22); print_r($b7); //echo $b7['wahab']; //Multi-dimensional arrays $c7 = array('friends'=> array('waleed', 'hammad', 'ali'), 'gfz'=> array('popo', 'mam', 'no one')); echo $c7['gfz'][0]; //for each statement $a8 = array('friends'=> array('waleed', 'hammad', 'ali'), 'gfz'=> array('popo', 'mam', 'no one')); foreach($a8 as $element => $inner_array) { echo '<u><b>'.$element.'</u></b></br>'; foreach($inner_array as $items) { echo $items.'</br>'; } }
//die and exit functions
//keywords: "die();" & "exit();"
@mysql_connect('localhost'.'root'.'') or die('Not connected');
echo 'Connected!';
for($c5=10; $c5>=1; $c5--) {
echo $c5.' ';
}
for($a6=1; $a6<=10; $a6++) {
echo $a6.' ';
}
//switch statement
$b6 = 1;
switch($b6) {
case 1:
echo 'One</br>';
break;
case 2:
echo 'Two';
break;
case 3:
echo 'Three';
break;
default:
echo 'number not found</br>';
break;
}
//Another switch statement
$c5 = 'black';
switch($c5) {
case 'red':
case 'yellow':
case 'green':
echo 'Traffic ligth color</br>';
break;
default:
echo 'Not a traffic ligth color</br>';
break;
}
//Array $a7 = array('waqas', 'wahab', 'waleed'); $a7[3] = 'hammad'; print_r($a7); //echo $a7[1].'</br>'; //Associative array $b7 = array('waqas'=>26, 'wahab'=>18, 'waleed'=>22); print_r($b7); //echo $b7['wahab']; //Multi-dimensional arrays $c7 = array('friends'=> array('waleed', 'hammad', 'ali'), 'gfz'=> array('popo', 'mam', 'no one')); echo $c7['gfz'][0]; //for each statement $a8 = array('friends'=> array('waleed', 'hammad', 'ali'), 'gfz'=> array('popo', 'mam', 'no one')); foreach($a8 as $element => $inner_array) { echo '<u><b>'.$element.'</u></b></br>'; foreach($inner_array as $items) { echo $items.'</br>'; } }
//die and exit functions
//keywords: "die();" & "exit();"
@mysql_connect('localhost'.'root'.'') or die('Not connected');
echo 'Connected!';
No comments:
Post a Comment