DWPD : Practical 14
1.Write PHP script Using user defined function<?php
function add($a,$b)
{
$c=$a+$b;
echo "Addition of $a & $b = $c";
}
add(5,6);
?>
Output:
2.Write PHP script to demonstrate use of string function<?php
$a=chr(65);
echo $a."<br>";
$b="a";
echo ord($b)."<br>";
$c="PHP";
echo strtolower($c)."<br>";
$d="mysql";
echo strtoupper($d)."<br>";
echo strlen($d)."<br>";
$e=" abc ";
echo ltrim($e)."<br>";
echo rtrim($e)."<br>";
echo trim($e)."<br>";
$f="Hello how are you ?";
echo substr($f,0,5)."<br>";
echo substr($f,6,3)."<br>";
echo substr($f,10,3)."<br>";
echo substr($f,14,5)."<br>";
$g="hello";
$h="hello";
$i="Hello";
echo strcmp($e,$f)."<br>";
echo strcmp($f,$e)."<br>";
echo strcmp($g,$h)."<br>";
echo strcasecmp($g,$h)."<br>";
echo strcasecmp($g,$f)."<br>";
echo strcasecmp($g,$i)."<br>";
echo strpos($g,"l")."<br>";
echo strstr($f,"ho")."<br>";
echo stristr($f,"yo")."<br>";
echo str_replace("world","PHP","hello world")."<br>";
echo strrev($f);
?>
Output:
Comments
Post a Comment