Professional Documents
Culture Documents
2CEIT6PE1 WT Practical-4-1
2CEIT6PE1 WT Practical-4-1
2CEIT6PE1 WT Practical-4-1
GANPAT UNIVERSITY
U.V. PATEL COLLEGE OF ENGINEERING B.Tech
6th Semester CE/IT
Practical-4
Aim: Perform following programs of PHP String & it’s inbuilt function.
Exercise:
Code :
<?php
// First String
$string1 = JINAL ';
// Second String
$string2 = 'ARDESHANA';
// Concatenation Of String
$concatenatestring= $string1.$string2;
OUTPUT:
1
21012012002 (Ardeshana Jinal)
IT-D(AB15)
Practical-4 Web Technology
Code :
<?php
$str1 = ‘ARDESHANA JINAL ‘;
echo strlen($str1);
echo "<br>";
$str2 = 'SURAT';
echo strlen($str2);
?>
OUTPUT:
2. Write a PHP program that will compare two stings whether they are
same or not.
Code :
<?php
// Declaration of strings
$name1 = "JINAL";
$name2 = "JINAL";
// Use == operator
if ($name1 == $name2) {
echo 'Both strings are equal';
}
else {
echo 'Both strings are not equal';
}
?>
OUTPUT:
2
21012012002 (Ardeshana Jinal)
IT-D(AB15)
Practical-4 Web Technology
3. Write a PHP program that will convert a string into lowercase string
and uppercase string.
Code :
<?php
$str =
"JINALARDESHNA "
;echo strtoupper($str);
echo strtolower($str);
?>
OUTPUT:
Code :
<?php
3
21012012002 (Ardeshana Jinal)
IT-D(AB15)
Practical-4 Web Technology
Code :
<?php
//input string
$string="JINAL ARDESHANA";
//replace geeks in the string with computer
echo str_replace("JINAL","RAVI",$string);
?>
OUTPUT:
Code :
<?php
function isVowel($ch)
{
;
return ($ch =='A' || $ch =='E' ||
$ch =='I' || $ch =='O' ||
$ch =='U'||$ch == 'a'||
$ch == 'e'||$ch == 'i'||
4
21012012002 (Ardeshana Jinal)
IT-D(AB15)
Practical-4 Web Technology
function countVowels($str)
{
$count = 0;
for ($i = 0; $i < strlen($str); $i++)if (isVowel($str[$i]))
++$count;
return $c
OUTPUT:
$a = 1;
$b = 100;
$d = 5;
printAP($a, $b, $d);
?>
OUTPUT:
6
21012012002 (Ardeshana Jinal)
IT-D(AB15)