PHP String Function - PowerPoint PPT Presentation

About This Presentation
Title:

PHP String Function

Description:

PHP string function helps us to manipulate string in various ways. There are various types of string function available. Here we discuss some important functions and its use with examples. – PowerPoint PPT presentation

Number of Views:476
Slides: 12
Provided by: instituteadmec
Tags:

less

Transcript and Presenter's Notes

Title: PHP String Function


1
PHP String Function
ADMEC MULTIMEDIA Leader in Animation Digital
Media Education ISO 90012008 CERTIFIED ADOBE
Testing Center www.admecindia.co.in
2
  • PHP string function helps us to manipulate string
    in various ways.
  • There are various types of string function
    available.
  • Here we discuss some important functions and its
    use with examples.
  • echo
  • strtolower ( )
  • strtoupper ( )
  • lcfirst()
  • ucfirst()
  • ucwords()
  • substr_replace ( )

3
1. echo It is used to print one or more string
.Echo function is faster than print print
function.   Example lt!doctype lt!DOCTYPE
htmlgt lthtmlgt ltheadgt lttitlegtstring
functionlt/titlegt lt/headgt ltbodygt lt?php echo
"String Function" ?gt lt/bodygt lt/htmlgt  Output
String Function //echo is not actually function
so we are not required to use parentheses with
it.
4
2. strtolower It converts a string to lower case
letter. Example lt!doctype lt!DOCTYPE
htmlgt lthtmlgt ltheadgt lttitlegtstring
functionlt/titlegt lt/headgt ltbodygt lt?php echo
strtolower("STRING Function") ?gt lt/bodygt lt/html
gt   Output string function
5
3. strtoupper ( ) It converts a string to upper
case letter. Example lt!doctype lt!DOCTYPE
htmlgt lthtmlgt ltheadgt lttitlegtstring
functionlt/titlegt lt/headgt ltbodygt lt?php echo
strtoupper("String Function") ?gt lt/bodygt lt/html
gt   Output STRING FUNCTION
6
4. lcfirst( ) It converts the first character of
a string to lower. Example lt!doctype lt!DOCTYPE
htmlgt lthtmlgt ltheadgt lttitlegtstring
functionlt/titlegt lt/headgt ltbodygt lt?php echo
lcfirst("String Function") ?gt lt/bodygt lt/htmlgt  
  Output string Function
7
5. ucfirst( ) It converts the first character of
a string to upper case. Example lt!doctype
lt!DOCTYPE htmlgt lthtmlgt ltheadgt lttitlegtstring
functionlt/titlegt lt/headgt ltbodygt lt?php echo
ucfirst("string function") ?gt lt/bodygt lt/htmlgt  
Output String function
8
6. ucwords( ) It converts the first character of
every word to upper case. Example lt!doctype
lt!DOCTYPE htmlgt lthtmlgt ltheadgt lttitlegtstring
functionlt/titlegt lt/headgt ltbodygt lt?php echo
ucwords("string function") ?gt lt/bodygt lt/htmlgt  
Output String Function
9
7. substr_replace( ) It replaces a part of a
string with another string. The syntax
is Substr_replace (string, replacement, start ,
length) There are various way to replace
string. Here the examples are Example lt!doctype
lt!DOCTYPE htmlgt lthtmlgt ltheadgt lttitlegtstring
functionlt/titlegt lt/headgt ltbodygt lt?php echo
substr_replace("hello world","nandon",6)
?gt lt/bodygt lt/htmlgt  
10
Output hello nandon //here it replace world to
nandon . Number 6 means the replacement starts
from 6 position of the string. Example
2 lt!doctype lt!DOCTYPE htmlgt lthtmlgt ltheadgt lttitle
gtstring functionlt/titlegt lt/headgt ltbodygt lt?php ec
ho substr_replace("hello world",
"nandon",-5) ?gt lt/bodygt lt/htmlgt Output
hello nandon //here in this example we use (-)
negative sign so it will count the word from the
right hand side and replace.
11
ADMEC MULTIMEDIA Leader in Animation
Digital Media Education ISO 90012008
CERTIFIED ADOBE Testing Center
ADMEC MULTIMEDIA INSTITUTE For
More information you can visit http//www.admeci
ndia.co.in
Contact for PHP Training ADMEC MULTIMEDIA
INSTITUTE C-7/114, IInd Floor, Sector- 7, Rohini,
Delhi- 85 Landmark Near Rohini East Metro Station
Helpline 1 91 9811 818 122 Helpline 2 91
9911 782 350
Write a Comment
User Comments (0)
About PowerShow.com