Untitled
unknown
plain_text
7 months ago
1.2 kB
4
Indexable
<html>
<head>
<title>String Functions</title>
</head>
<body>
<h2>PHP program to demonstrate string fnction</h2>
<form method="post">
Enter String 1:<input type="text" name="s1" requried value="<?php echo isset($_POST['s1'])?$_POST['s1']: '';?>"> <br><br>
Enter String 2:<input type="text" name="s2" requried value="<?php echo isset($_POST['s2'])?$_POST['s2']: '' ;?>"> <br><br>
<input type="submit" name="submit" value="Submit">
</form>
<br>
<?php
if(isset($_POST['submit'])){
$n1=$_POST['s1'];
$n2=$_POST['s2'];
echo "Results";
echo"String 1 Before:".$n1."<br>";
echo"String 2 Before:".$n2."<br>";
echo "The length of String 1 is: ".strlen($n1)."<br>";
echo "The reverse of String 2 is: ".strrev($n2)."<br>";
echo "The replaced of String 1 is: ".str_replace($n1,"JGI",$n1)."<br>";
echo "The number of words in String 2 are : ".str_word_count($n2)."<br>";
echo "String 1 in Uppercase : ".strtoupper($n1)."<br>";
echo "String 2 in Lowewrcase : ".strtolower($n1)."<br>";
if(strcmp($n1,$n2)==0)
{
echo "The Strings are equal.<br>";
}
else{
echo "The Strings are NOT Equal.<br>";
}
}
?>
</body>
</html>Editor is loading...
Leave a Comment