0% found this document useful (0 votes)
6 views5 pages

PR 5

The document outlines a laboratory experiment for a 6th semester Computer Engineering course focused on web-based application development with PHP. It includes tasks for writing PHP programs to calculate string length and word count without using built-in string functions, as well as demonstrating various string functions. The document provides code examples for each experiment along with expected outputs.

Uploaded by

sunitadsouza1975
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views5 pages

PR 5

The document outlines a laboratory experiment for a 6th semester Computer Engineering course focused on web-based application development with PHP. It includes tasks for writing PHP programs to calculate string length and word count without using built-in string functions, as well as demonstrating various string functions. The document provides code examples for each experiment along with expected outputs.

Uploaded by

sunitadsouza1975
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

DEPARTMENT OF COMPUTER ENGINEERING

Subject: Web Based Application Subject Code: 22619


Development with PHP
Semester: 6th Semester Course: Computer Engineering
Laboratory No: Name of Subject Teacher: Prof. Sneha
Patange
Name of Student: Canute Mendonza Roll Id: 2220C0006

Experiment Title of Experiment Application


No:
5 A. Write a PHP program to 1. Write a Script to
a) Calculate length of string implement all string
without using string functions. functions.
b) Calculate number of words 2. Write a Script to count
without using string functions. length of the string without
string functions.
B. Write a simple PHP 3. Write a Script to count
program to demonstrate use of number of words in a string
various built in string without string function.
functions.

Q1 Implement all string functions

Code
<?php
$str = "Hello World of PHP";
echo "Original string: ".$str."\n";
echo "Word Count \n";
echo str_word_count($str)."\n";
echo "String Lenght \n";
echo strlen($str)."\n";
echo "String Repeat \n";
echo str_repeat($str,2)."\n";
echo "String Replace \n";
echo str_replace("World","PHP",$str)."\n";
echo "String Replace \n";
echo str_replace("PHP","World",$str)."\n";
echo "String Compare Hello and Hello\n";
echo strcmp("Hello","Hello")."\n";
echo "String Compare Hello and hello\n";
echo strcmp("Hello","hello")."\n";
echo "String split \n";
$s = str_split($str);
print_r($s)."\n";
echo "String Reverse \n";
echo strrev($str)."\n";
echo "String Lowercase \n";
echo strtolower($str)."\n";
echo "String Uppercase \n";
echo strtoupper($str)."\n";
echo "String Ucwords \n";
echo ucwords($str)."\n";
echo "String position of World\n";
echo strpos($str,"World")."\n";
echo "String Shuffle \n";
echo str_shuffle($str)."\n";
echo "String Trim \n";
echo trim($str)."\n";
echo "String Rtrim \n";
echo rtrim($str)."\n";
echo "String Ltrim \n";
echo ltrim($str)."\n";
echo "String Chop \n";
echo chop($str,"PHP")."\n";
echo "String Chunk Split \n";
echo chunk_split($str,5)."\n";
?>
Output
Q2 Find the length of a string without using string functions

Code
<?php
$input = "Mohit";
$count = 0;

while (isset($input[$count])) {
$count++;
}

echo "The length of the string is: " . $count;


?>
Output

Q3 Find the number of words in a string without using string functions

Code

<?php
$str = "Mohit Chaudhari";
$arr = explode(" ",$str);
$coun = count($arr);
echo "No of words in ".$str." is ".$coun."\n";
?>
Output
Grade and Process Related Product Related Dated Sign
Dated (15) (10)
Signature
of Teacher

You might also like