[go: up one dir, main page]

0% found this document useful (0 votes)
8 views2 pages

Prac 5 FPDF

The document outlines a PHP practical assignment focused on string manipulation, including calculating string length and counting words. It provides a list of built-in PHP string functions with their syntax and purposes. A sample PHP code demonstrates the use of these functions to manipulate a given string.

Uploaded by

Sami Md
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)
8 views2 pages

Prac 5 FPDF

The document outlines a PHP practical assignment focused on string manipulation, including calculating string length and counting words. It provides a list of built-in PHP string functions with their syntax and purposes. A sample PHP code demonstrates the use of these functions to manipulate a given string.

Uploaded by

Sami Md
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/ 2

Name: Faizan Saeedahmad momin Class: CO6IB Batch: B1

Enrollment No: 2205690316 Subject: WBP Practical No: 5

Aim:

a. Write a php program to calculate length of string and count the number of string.
b. Write a simple php program to demonstrate the use of various built-in string function

Theory:

PHP provides a wide range of built-in string functions to manipulate and process strings effectively.
Below is a comprehensive list of PHP string functions along with their syntax and purpose:

String Functions:-

1. strlen()
o Purpose: Returns the length of a string (number of characters).
o Syntax: strlen($string);
2. str_word_count()
o Purpose: Counts the number of words in a string.
o Syntax: str_word_count($string);
3. strrev()
o Purpose: Reverses a string.
o Syntax: strrev($string);
4. strtoupper()
o Purpose: Converts all characters in a string to uppercase.
o Syntax: strtoupper($string);
5. strtolower()
o Purpose: Converts all characters in a string to lowercase.
o Syntax: strtolower($string);
6. ucwords()
o Purpose: Capitalizes the first character of each word in a string.
o Syntax: ucwords($string);
7. strpos()
o Purpose: Finds the position of the first occurrence of a substring in a string.
o Syntax: strpos($string, $substring);
8. str_replace()
o Purpose: Replaces all occurrences of a search string with a replacement string.
o Syntax: str_replace($search, $replace, $string);
Code:

<?php

$str = "Welocome to the world od PHP";


echo "Actual String: $str<br>";
echo "<br>String Length: ",strlen($str);
echo "<br>String in reverse Order: ",strrev($str);
echo "<br>String in Upper case: ",strtoupper($str);
echo "<br>String in Lower case: ",strtolower($str);
echo "<br>Wide Spaces in String: ",str_word_count($str);
echo "<br>Change the first letter into Capital case: ",ucwords($str);

?>

Output:

You might also like