0% found this document useful (0 votes)
36 views

Samarth Polytechnic Belhe: Department of Computer Engineering

Uploaded by

Shekhar Jadhav
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views

Samarth Polytechnic Belhe: Department of Computer Engineering

Uploaded by

Shekhar Jadhav
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Samarth Polytechnic Belhe

DEPARTMENT OF COMPUTER ENGINEERING

Subject : Web Based application development using PHP. Subject code : 22619

Semester : 6th Course : Computer Engineering


Name of Subject Teacher: Prof.Kshirsagar. S. B Laboratory No:L001B
Name of Student: Phapale Siddhesh Ramdas Enrollment no: 2009920220
Date of Performance: / /2022 Date of Submission: / /2022

Experiment No: 5

Title of Experiment: a) Write a PHP program to calculate


length of string and count number of
words in a string without using string
function.
b) Write a PHP program to demonstrate
the use of built in stringfunction.

Theory:
Title:
a) Write a PHP program to calculate length of string and count number of words in astring
without using stringfunction.
b) Write a PHP program to demonstrate the use of built in stringfunction.

2.0 String concept:


It is sequence of characters enclosed within pair of single quotation marks or double quotation mark.

New Concepts: String


Functions:
1. str_word_count(): count the number of words in thestring
2. strlen(): return the length ofstring
3. strrev(): reverse astring
4. strops(): returns position of first occurrence ofstring
5. str_replace(): replaces some characters in astring
6. ucwords(): convert first character each word into uppercase
7. strtoupper(): convert string to uppercaseletters
8. strtolower(): convert string to lowercaseletters
9. strcmp(): compare twostrings

Learing Ojectives:

IntellectualSkills:
1. To understand the concept ofstring
2. To understand the use of functions ofstring
Motor Skills:
1. Ability to use string functions to solveproblems
2. Ability to use PHP webservers.

5.0 Apparatus:

Srno Equipment Name with broad specification Practical


1 Hardware : any computer system (preferably i3 or i5) All
2 Operating System: Windows/Linux All

3 Any Database tool such as MYSQL,MariaDB 15,16

Strlen():

Program: -

<?php
$str="Siddhesh";
$result=strlen($str);
echo$result;
?>

Output:-
String_word_count():

Program:-

<?php
$str="samarth polytechnic belhe";
$result=str_word_count($str);
echo $result;
?>

Output:

Strrev():

Program:-

<?php
$str="Siddhesh";
$result=strrev($str);
echo$result;
?>

Output:
Str_replace():

Program:

<?php
$str="Siddhesh";
$result=str_replace("Siddhesh","Phapale","Siddhesh");
echo$result;
?>
Output:

Strcmp():

Program:

<?php
$str1="Siddhesh";
$str2="SiddheshPhapale";
$result=strcmp($str1, $str2);
echo $result;
?>

Output:
Without Using String Function:

Program:

<?php
$var="Phapale Siddhesh Ramdas";
$wordcount=0;
for($i=0; $i<strlen($var)-1; $i++)
{
if($var[$i]==' '&&ctype_alpha($var[$i+1])&&($i>0))
{
$wordcount++;
}
}
$wordcount++;
print_r("Total Word Count is $wordcount");
?>

Output:

Process Product Total Dated Sign Of


Grade and Related Related (25 M) Teacher
Dated Signature of (15M) (10M)
Teacher

You might also like