1.Display prime no.
";
for($i=$start; $i<$send; $i++)
{
if(isPrime($i))
{
echo $i."";
$count++;
}
}
echo "
total prime no. between $start and $end:
".$count;
}
$start=1;
$end=10;
displayPrimeInRange($start,$end);
?>
#2 message passing
Message passing
#3.simple calculator
simple calculator
#4. string function
";
$str1="Change your thoughts and you can change the world";
$str2="The first programmer was women";
echo "The given string are:
";
echo "String 1 is: $str1
";
echo "String 2 is: $str2
";
$len=strlen($str1);
echo "The length of string 1 is: $len";
$word_count=str_word_count($str1);
echo "
The total word of string 1 is: ".$word_count;
$capitalized=ucwords($str1);
echo "
Uppercase of each word is:\n ".$capitalized;
$upper=strtoupper($str1);
echo "
The upper case of String is:\n $upper";
$reverse=strrev($str1);
echo "
The reverse of string is:\n $reverse";
$compare=strcmp($str1, $str2);
echo nl2br("
The comparision of string 1 and string 2 is:\n $compare");
$repeate=str_repeat($str1,3);
echo "
Repetation: \n $repeate";
?>
5.Array function
Minimum number is:".min($arr);
echo "
Maximum number is:".max($arr); sort($arr);
echo "
The sorted Array is:";
foreach($arr as $value)
{
echo $value.",";
}
rsort($arr);
echo "
The Reverse sorted array is:"; foreach($arr as $value)
{
echo $value.",";
}
array_pop($arr);
echo "
After pop the array is:";
foreach($arr as $value)
{
echo $value.",";
}
array_push($arr, '50');
echo "
After push the array is:"; foreach($arr as $value)
{
echo $value.",";
}
?>
#6. Display time
date_default_timezone_set('Asia/Calcutta');
$hour=date('G');
echo "the currrent time is (In 24 hr format):".$Hour."-";
if($Hour<"12")
{
echo "Good Morning"'
}
else if("Hour >="12" && &Hour <="18:00")
{
echo "Good afternoon";
}
else if("Hour >="18" && &Hour <="21")
{
echo "Good evening";
}
else if("Hour >="21" && &Hour <="21")
{
echo "Good night";
}
?>
7.GCD LCM
GCD and LCM
8.Constructor
a=10;
$this->b=20;
}
function add()
{
$sum=$this->a+$this->b;
echo "Addition of a and b is:".$sum;
}
function __destruct()
{
echo "
Destruct() function is called";
}
function sub()
{
$sub=$this->a-$this->b;
echo "
sub of a and b is:".$sub;
}
}
$object1 = new ArithmaticOperation();
$object1->add();
$object1->sub();
unset($object1);
?>
9.exception handling
Program-10
Insert Information
Search Information