Advertisement
AlaminSakib

PHP Basics 2

Feb 7th, 2020
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.50 KB | None | 0 0
  1. <?php
  2.  
  3. $a = 2;
  4. $name = "Alamin Shaheen";
  5. $age = 23;
  6. $num1 = 100;
  7. $num2 = 5000;
  8. $num3 = 30;
  9.  
  10. // strlen gives string length
  11. // echo strlen($name);
  12.  
  13.  
  14. // condition
  15.  
  16.  
  17.  
  18. // if($num1 % 2 == 0) echo "Even";
  19. // else echo "Odd";
  20.  
  21. // if($num1 > $num2 && $num1 > $num3) echo "Num1 is highest";
  22. // else if($num2 > $num1 && $num2 > $num3) echo "Num2 is highest";
  23. // else echo "Num3 is highest";
  24.  
  25. // if($age == 23 || $name == "Alamin Shaheen")
  26. // {
  27. //  echo "Found";
  28. // }
  29. // else if(a == 2)
  30. // {
  31. //  echo "congrats!"
  32.  
  33. // }
  34. // else echo "Not found";
  35.  
  36.  
  37. // the "===" operator checks if both the value and type are same
  38. // if($name === "Alamin Shaheen")
  39. // {
  40. //  echo "Found";
  41. // }
  42. // else
  43. // {
  44. //  echo "Not found";
  45. // }
  46.  
  47. // functions
  48.  
  49. // function can be called before function is made
  50. // echo greet("Alamin", "Shaheen");
  51.  
  52. // echo checker(100);
  53. // function checker($num)
  54. // {
  55. //  if($num % 2 == 0) return "Even";
  56. //  else return "Odd";
  57. // }
  58.  
  59. // function greet($name1, $name2)
  60. // {
  61. //  return $name1." ".$name2;
  62. // }
  63. // echo greet("Alamin", "Shaheen");
  64.  
  65. // loops
  66.  
  67. // for($i = 0; $i < 100; $i++)
  68. // {
  69. //  echo "Md. Alamin Shaheen"."<br>";
  70. // }
  71.  
  72. // $i = 1;
  73. // while($i <= 10)
  74. // {
  75. //  echo $i." ";
  76. //  $i++;
  77. // }
  78.  
  79. // do
  80. // {
  81. //  echo $i;
  82. //  $i++;
  83. // }while ($i < 11);
  84.  
  85. // switch case
  86. // $i = 8;
  87. // switch ($i) {
  88. //  case 1:
  89. //      echo "1";
  90. //      break;
  91. //  case 2:
  92. //      echo "2";
  93. //      break;
  94. //  default:
  95. //      echo "Kichu nai";
  96. //      break;
  97. // }
  98.  
  99.  
  100.  
  101. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement