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

PHP PR5 (22203C0007)

The document outlines a laboratory experiment for a 6th semester Computer Engineering course on Web Based Application Development with PHP. It includes tasks for writing PHP programs to calculate string length and word count using both built-in string functions and manual methods. The document also provides code examples for each task along with expected outputs.

Uploaded by

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

PHP PR5 (22203C0007)

The document outlines a laboratory experiment for a 6th semester Computer Engineering course on Web Based Application Development with PHP. It includes tasks for writing PHP programs to calculate string length and word count using both built-in string functions and manual methods. The document also provides code examples for each task along with expected outputs.

Uploaded by

adityadarekar919
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as 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: L001C Name of Subject Teacher: Prof. Sneha


Patange

Name of Student: Aditya Darekar Roll Id: 22203C0007

Experiment Title of Experiment Application


No:
5 A. Write a PHP program to 1. Write a Script to implement all
a) Calculate length of string without string functions.
using string functions. 2. Write a Script to count length of
b) Calculate number of words without the string without string functions.
using string functions. 3. Write a Script to count number of
words in a string without string
B. Write a simple PHP program to function.
demonstrate use of various built in string
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 = "Student";
$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 = "student id";
$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