php ppt
php ppt
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
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;
?>