Write a PHP script to perform the following operations on string : i) Compare string 2 with string3. ii) Convert all the strings to Upper case iii) Convert all the strings to Lowercase
Assignment:3 Set B Q.1 Solution
Q.1. Write a PHP script to perform the following operations on string : i) Compare string 2 with string3. ii) Convert all the strings to Upper case iii) Convert all the strings to Lowercase
<?php
//input 3 strings
echo"Enter string 1\n";
$s1=readline();
echo"Enter string 2\n";
$s2=readline();
echo"Enter string 3\n";
$s3=readline();//Comparing string 2 with string 3if(strcmp($s2,$s3)==0)
{
echo"The strings are equal\n";
}
else
{
echo"Values of string are not equal\n";
}
//Transform all strings to lower
echo"Strings to lower:\n";
echo strtolower($s1)."\n";
echo strtolower($s2)."\n";
echo strtolower($s3)."\n";//Transform all strings to upper
echo"Strings to upper:\n";
echo strtoupper($s1)."\n";
echo strtoupper($s2)."\n";
echo strtoupper($s3)."\n";
?>
0 Comments