Posted On: Jun 05, 2021
The program in Php to check whether a number is prime or not is as follows :
<?php
function primeCheck($number){
if ($number == 1)
return 0;
for ($i = 2; $i <= $number/2; $i++){
if ($number % $i == 0)
return 0;
}
return 1;
}
$number = 31;
$flag = primeCheck($number);
if ($flag == 1)
echo "Prime";
else
echo "Not Prime"
?>
Never Miss an Articles from us.
The program to find no of days between two dates in PHP is as follows: Let the dates are 25-09-2020 and 31-01-2021 <?php function dateDiffInDays($date1, $date2) { &nbs...
The program in PHP to find the occurrence of a word in a string is as follows: <?php $s1 = "interviewmocks.com is a interview prep site"; $s2 = "interview"; $res = substr_count($s1, $s2); echo...
The program to upload a file in PHP is as follows: <?php $target_dir = "uploads/"; $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]); $uploadOk = 1; $imageFileType = strto...