Prac 5 FPDF
Prac 5 FPDF
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
?>
Output: