abcd - noorshuvo95/CSE327-Software-Engineering GitHub Wiki

`<?php //Documentation //phpDoc // PHP code to check wether a number is Prime or Not /*Function to check whether the number is Prime or Not

  • Function pass by value *@par int $n *@par int $x *return bool / function isPrime($n) { for($x=2; $x<$n; $x++) { if($n %$x ==0) { return 0; } } return 1; } / Calling the function with passing a value and assigning the function in to a parameter
    • We will print the number if it is prime or not *@par int $a */ $a = isPrime(4); if ($a==0) //Here echo command is used to print echo 'This is not a Prime Number and'; else echo 'This is a Prime Number'."and";

/* PHP code to find the Max element from an array *function pass by value

  • @par int $array
  • @par int $n
  • @par int $i
  • @par int $max
  • return int $max */

function maxElement($array) { $n = count($array); $max = $array[0]; for ($i = 1; $i < $n; $i++) if ($max < $array[$i]) $max = $array[$i]; return $max;

} /* calling the function with passing five index value in array

  • @para int $array
  • print maxElement
  • print call_user_func maxElement */ $array = array(10, 24.6, 0, 67.8, 2,31.7);

echo ' Max Element is '; echo (maxElement($array));

?>

`