Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
2 views

php ppt

The document provides an overview of various PHP string handling functions including strtolower(), strtoupper(), ucfirst(), lcfirst(), strrev(), strlen(), and str_replace(). Each function is explained with its syntax, purpose, and an example demonstrating its use. These functions are essential for manipulating string cases, reversing strings, measuring string length, and replacing substrings in PHP.

Uploaded by

21BIT032 Sam
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

php ppt

The document provides an overview of various PHP string handling functions including strtolower(), strtoupper(), ucfirst(), lcfirst(), strrev(), strlen(), and str_replace(). Each function is explained with its syntax, purpose, and an example demonstrating its use. These functions are essential for manipulating string cases, reversing strings, measuring string length, and replacing substrings in PHP.

Uploaded by

21BIT032 Sam
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 8

STRING HANDLING

BY 21BIT032_SAM
PHP STRTOLOWER() FUNCTION
The strtolower() function returns string in lowercase letter.
This function takes a string as argument ans returns the string with all of the characters in Lower Case.
Syntax
string strtolower ( string $string )

Example
<?php
$str=“My name is KHAN”;
$str=strtolower($str);
echo $str;
?>
Output:
my name is khan
PHP STRTOUPPER() FUNCTION

The strtoupper() function returns string in uppercase letter.


This function takes a string as argument and returns the string with all characters in Upper Case.
Syntax
string strtoupper ( string $string )

Example
<?php
$str=“My name is KHAN”;
$str=strtoupper($str);
echo $str;
?>

Output:
MY NAME IS KHAN
PHP UCFIRST() FUNCTION
The ucfirst() function returns string converting first character into uppercase. It doesn’t change the case of
other characters.
This function takes a string as argument and returns the string with the first character in Upper Case and all
other cases of the characters remains unchanged.
Syntax
string ucfirst ( string $str )

Example
<?php
$str=“my name is KHAN”;
$str=ucfirst($str);
echo $str;
?>
Output:
My name is KHAN
PHP LCFIRST() FUNCTION
The lcfirst() function returns string converting first character into lowercase. It doesn’t change the case of
other characters.
This function takes a string as argument and returns the string with the first character in Lower Case and all
other characters remains unchanged
Syntax
string lcfirst ( string $str )
Example
<?php
$str=“MY name IS KHAN”;
$str=lcfirst($str);
echo $str;
?>
Output:
mY name IS KHAN
PHP STRREV() FUNCTION
The strrev() function returns reversed string.
It also Reverses a string by reversing the order of its characters
Syntax
string strrev ( string $string )
Example
<?php
$str=“my name is Sonoo jaiswal”;
$str=strrev($str);
echo $str;
?>

Output:
lawsiaj oonoS si eman ym
PHP STRLEN() FUNCTION
The strlen() function returns length of the string.
Syntax
int strlen ( string $string )
Example
<?php
$str=“my name is Sonoo jaiswal”;
$str=strlen($str);
echo $str;
?>
Output:
24
PHP STR_REPLACE() FUNCTION
The str_replace() function is a case-sensitive, built-in function of PHP which replaces some character of the
string with other characters. It is used to replace all the occurrences of the search string with the
replacement string.
Syntax:
Str_replace ( $search, $replace, $string, $count)
Example: Output
<?php
$string = “Hii everyone!”;
$search = ‘Hii’;
$replace = ‘Hello’;
echo ‘<b>’.”String before replacement:”.’</br></b>’;
echo $string.’</br>’;
$newstr = str_replace($search, $replace, $string, $count);
echo ‘<b>’.”New replaced string is:".'</br></b>';
echo $newstr.'</br>';
echo 'Number of replacement ='.$count;
?>

You might also like