PHP Part-1 Code ?



PHP PART- 1 Code  -:


<?php 
/*
//operators 
//1. assignment operators
$var1 = 12;
echo $var1 . '<br>';

//2.increment operator
//prefix 

$var2 = ++$var1;  //12+1
echo $var2 . "<br>"; //13
//postfix
$var3 = $var1++; //13
echo $var3 . '<br>';  
echo 'var1 = '.$var1; //14

//3.decrement operator
$var1--; //13
echo '<br>'.$var1 .'<br>';
--$var1; //12
echo $var1 .'<br>';
//concatenation operator
$str = 'master-tech';
$str2 = '786';
$str3 = $str.$str2;
echo '<br>'. $str .'<br>'.$str3;

//==  (data)
$f = 12; //integer
$s = '12'; //string
if($f==$s) {
echo '<br>' . 'same data but not say about type';
}
//=== (type + data)
if($f===$s) {
echo '<br>' . 'same data with type';
}
else{
echo '<br>' . 'Not same data with type';
}
//addition
$var = 1;
$var123 = 2;
$var321 = $var+$var123;
$vars = $var-$var123; //sub
$varm = $var*$var123; //mul
$vard = $var/$var123; //div

 echo '<br>' . $var321;
 echo '<br>' . $vars;
 echo '<br>' . $varm;
 echo '<br>' . $vard;*/
 //if else ladder
/* $var = '12';
 $var2 = 12;
 if($var==$var2) {
  echo '<br> if';
 }
 else if($var===$var2){
  echo '<br> f else if';
 }
else if($var!=$var2) {
echo '<br> s else if';
 } 
 else{
  echo '<br>  else ';
 }
*/
//for loop
 // 2 upto 10 table
/* for($t = 1; $t<=10; $t++) {
  echo '2 * '.$t.' = '. $t*2 . '<br>';
 }*/

 //while
/* $w = 1;
 while($w <= 10) {
  echo '2 * '.$w.' = '. $w*2 . '<br>';
  $w++;
 }*/
 //do - while
/* $d = 1;
 do {
  echo '2 * '.$d.' = '. $d*2 . '<br>';
  $d++;
 }while($d<=10);
*/

/* //ARRAY 1
 $arr = array(10, 'str', '12.5'); //1
 $arr1 = array('a'=>10, 'str', '12.5'); //1
 echo $arr1['a'] . '<br>';
 print_r($arr1);*/
 //ARRAY 1
/* $arr = [10, 'str', '12.5']; //1
 $arr1 = ['a'=>10, 'str', '12.5', 'hello']; //1
 echo $arr1['a'] . '<br>';
 print_r($arr1);
 foreach($arr1 as $var) {
  echo $var . '<br>';
 }*/
//function 
/* $n = "Mohd Umar";
 function sayName($name) {
  global $n;
  echo $name;
  return 'hello';
 }
$r = sayName($n);
echo '<br>'.$r;*/
/*header('location:header.php');*/
/*require_once('header.php');
require_once('header.php');
echo "Mohd Umar";
*/
// 2 dimensional array 
?>

No comments