Practical 2 teni
Practical 2 teni
Practical 2 teni
1CE2502
array("Het",1142,"Unjha"),
array("Dhruv",1159,"Gandhinagar"), );
echo " <table> ";
for($i=0;$i<4;$i++)
{
echo "<tr>";
for($j=0;$j<3;$j++)
{
echo "<td>" . $mld [$i][$j] ."</td> ";
}
echo "</tr>";
} echo "</table>"; ?>
</body>
</html>
Output:
Valay
Va
Practical 2: Write PHP script for checking that given number is prime
or not using user- defined function.
<!DOCTYPE html>
<html>
<head>
<title>pr22</title>
</head>
<body>
<?php
$a=3;
function prime($a){
$i=2;
while($i<$a)
{
if($a % $i==0)
{
return 0;
}
$i++;
}
return 1;
}
$p=prime($a);
if($p==0){
echo "$a is not prime";
}
else { echo "$a is prime."; }
?>
</body>
</html>
Output:
Output:
$a=8;
$get=gettype($a);
$st=false;
$m="3.4mm";
settype($st,"integer");
settype($m,"float");
if(isset($a)) //isset()
unset($a); //unset()
$val="MP114";
$f="1.2gh";
$no=array(10,"meet",false,4.5);
print_r($no); //print_r()
echo "<br>";
var_dump($no);
?>
Output:
Output:
VALAY PATEL
Output:
$mode = current($ar);
echo "<br>". $mode;
$mode = next($ar);
echo "<br>". $mode;
$mode = current($ar);
echo "<br>". $mode;
$mode = prev($ar);
echo "<br>". $mode;
$mode = end($ar);
echo "<br>". $mode;
$mode = current($ar);
echo "<br>". $mode;
Output:
Output: