SlideShare a Scribd company logo
Strings
strings in php how to use different data types in string
strings in php how to use different data types in string
Single Quoted
• The simplest way to create a string is to enclose the string literal (i.e.
string characters) in single quotation marks ('), like this:
Double-quote strings
• Unlike single-quote strings, double-quote strings in PHP are capable
of processing special characters.
strings in php how to use different data types in string
strings in php how to use different data types in string
strings in php how to use different data types in string
We can perform several functions on string in PHP . The string manipulation functions are.
PHP Strings
A string is a sequence of characters, like "Hello world!".
we will look at some commonly used functions to manipulate strings.
strlen() - Return the Length of a String
The PHP strlen() function returns the length of a string.
str_word_count() - Count Words in a String
The PHP str_word_count() function counts the number of words in a string.
strrev() - Reverse a String
The PHP strrev() function reverses a string.
trim() function:
• This function allows us to remove whitespaces or strings from both
sides of a string.
strings in php how to use different data types in string
str_replace() - Replace Text Within a String
The PHP str_replace() function replaces some characters with some other characters in a string.
strtolower() function:
• This function converts a string into the lowercase string.
strtoupper() function:
• This function converts a string into the uppercase string.
Comparing Strings
PHP strcmp() Function
Comparing Strings
PHP strcmp() Function
Comparing Strings
The strcmp() function compares two strings.
The strcmp() function is binary-safe and case-sensitive.
Cleaning Strings
The trim() function removes whitespace and other predefined characters from both sides
of a string.
Related functions:
•ltrim() - Removes whitespace or other predefined characters from the left side of a
string
•rtrim() - Removes whitespace or other predefined characters from the right side of a
string
Cleaning Strings
Cleaning Strings
chop() Function
• The chop() function is used to remove whitespace or other predefined
character from the right end of a string.
• Syntax: chop(string,charlist);
• Example
<?php
$str = "Hello World!";
echo "Your string is :".$str."<br>";
echo "By using 'chop()' Functions is your string is: ".chop($str,"World!");
?>
Parameter Description Required/Optional
string the string to be
check
Required
charlist charlist parameter
is empty
Optional
Output:
Your string is :Hello
World!
By using 'chop()'
Functions is your
string is: Hello
PHP chunk_split() Function
• PHP chunk_split() function is used to splits a string into smaller parts
or chunks. The function does not alter the original string.
• Syntax: chunk_split(string,length,end)
<?php
$str = "Hello!;
echo "Your string is:".$str;
echo "By using 'chunk_split()' function your string is:".chunk_split($str,1,".
..");
?>
Parameter Description Required/Optional
string String to split Required
Length Specify the length of the
chunks. Default is 76
Optional
end Specify what to place at
the end each chunk.
Optional
Output:
Your string is: Hello
By using 'chunk_split()' function your string
is: H…e...l...l...o...!...
PHP type casting
• Type casting allows you to convert a value of one type to another.
To cast a value, you use the following type casting operators:
Which of the following functions is used to find
the first occurrence of a substring in a string?
• strlen()
• strpos()
• str_replace()
• str_split()
Which of the following functions is used to find
the first occurrence of a substring in a string?
• strlen()
• strpos()
• str_replace()
• str_split()
Which of the following functions is used to replace all
occurrences of a substring in a string with another substring?
• strlen()
• strpos()
• str_replace()
• str_split()
Which of the following functions is used to replace all
occurrences of a substring in a string with another substring?
• strlen()
• strpos()
• str_replace()
• str_split()
Which of the following functions is used to
count the number of words in a string?
• strlen()
• strpos()
• str_replace()
• str_word_count()
Which of the following functions is used to
count the number of words in a string?
• strlen()
• strpos()
• str_replace()
• str_word_count()
Which of the following is not a built-in PHP
function for working with strings?
• strlen()
• strpos()
• str_replace()
• str_split()
• strrev()
Which of the following is not a built-in PHP
function for working with strings?
• strlen()
• strpos()
• str_replace()
• str_split()
• strrev()
What is the following is the output of the following PHP code?
•
• $str = "Hello, world!";
• echo strlen($str);
• 13
What is the following is the output of the following PHP code?
• <?php
• $str = "Hello, world!";
• echo strpos($str, "world");
• ?>
• 7
What is the following is the output of the following PHP code?
• <?php
• $str = "Hello, world!";
• echo str_replace("world", "universe", $str);
• ?>
• Hello universe
What is the following is the output of the following PHP code?
• <?php
• $str = "Hello, world!";
• echo $str[0];
• ?>
• H

More Related Content

Similar to strings in php how to use different data types in string (20)

Strings cprogramminglanguagedsasheet.pptx
Strings cprogramminglanguagedsasheet.pptxStrings cprogramminglanguagedsasheet.pptx
Strings cprogramminglanguagedsasheet.pptx
hyundaitvhamari
 
presentation template........msk....pptx
presentation template........msk....pptxpresentation template........msk....pptx
presentation template........msk....pptx
shoaibbutt105
 
9780538745840 ppt ch03
9780538745840 ppt ch039780538745840 ppt ch03
9780538745840 ppt ch03
Terry Yoast
 
Strings
StringsStrings
Strings
Saranya saran
 
introduction to server-side scripting
introduction to server-side scriptingintroduction to server-side scripting
introduction to server-side scripting
Amirul Shafeeq
 
characters_strings.pdf
characters_strings.pdfcharacters_strings.pdf
characters_strings.pdf
HoPeTaylor7
 
00012.PYTHON - STRING MANIPULATION SLIDES
00012.PYTHON - STRING MANIPULATION SLIDES00012.PYTHON - STRING MANIPULATION SLIDES
00012.PYTHON - STRING MANIPULATION SLIDES
PanavGupta3
 
Introduction to Python for Bioinformatics
Introduction to Python for BioinformaticsIntroduction to Python for Bioinformatics
Introduction to Python for Bioinformatics
José Héctor Gálvez
 
All_About_Strings.pptxxbsnsnsmsmsmmmsmsmsm
All_About_Strings.pptxxbsnsnsmsmsmmmsmsmsmAll_About_Strings.pptxxbsnsnsmsmsmmmsmsmsm
All_About_Strings.pptxxbsnsnsmsmsmmmsmsmsm
kumarsahil80682
 
BCSE101E_Python_Module5 (4).pdf
BCSE101E_Python_Module5 (4).pdfBCSE101E_Python_Module5 (4).pdf
BCSE101E_Python_Module5 (4).pdf
mukeshb0905
 
Python basics
Python basicsPython basics
Python basics
Hoang Nguyen
 
Python basics
Python basicsPython basics
Python basics
Harry Potter
 
Python basics
Python basicsPython basics
Python basics
Fraboni Ec
 
Python basics
Python basicsPython basics
Python basics
James Wong
 
Python basics
Python basicsPython basics
Python basics
Tony Nguyen
 
Python basics
Python basicsPython basics
Python basics
Luis Goldster
 
Python basics
Python basicsPython basics
Python basics
Young Alista
 
unit-5 String Math Date Time AI presentation
unit-5 String Math Date Time AI presentationunit-5 String Math Date Time AI presentation
unit-5 String Math Date Time AI presentation
MukeshTheLioner
 
Web Application Development using PHP Chapter 3
Web Application Development using PHP Chapter 3Web Application Development using PHP Chapter 3
Web Application Development using PHP Chapter 3
Mohd Harris Ahmad Jaal
 
Advance topics of C language
Advance  topics of C languageAdvance  topics of C language
Advance topics of C language
Mehwish Mehmood
 
Strings cprogramminglanguagedsasheet.pptx
Strings cprogramminglanguagedsasheet.pptxStrings cprogramminglanguagedsasheet.pptx
Strings cprogramminglanguagedsasheet.pptx
hyundaitvhamari
 
presentation template........msk....pptx
presentation template........msk....pptxpresentation template........msk....pptx
presentation template........msk....pptx
shoaibbutt105
 
9780538745840 ppt ch03
9780538745840 ppt ch039780538745840 ppt ch03
9780538745840 ppt ch03
Terry Yoast
 
introduction to server-side scripting
introduction to server-side scriptingintroduction to server-side scripting
introduction to server-side scripting
Amirul Shafeeq
 
characters_strings.pdf
characters_strings.pdfcharacters_strings.pdf
characters_strings.pdf
HoPeTaylor7
 
00012.PYTHON - STRING MANIPULATION SLIDES
00012.PYTHON - STRING MANIPULATION SLIDES00012.PYTHON - STRING MANIPULATION SLIDES
00012.PYTHON - STRING MANIPULATION SLIDES
PanavGupta3
 
Introduction to Python for Bioinformatics
Introduction to Python for BioinformaticsIntroduction to Python for Bioinformatics
Introduction to Python for Bioinformatics
José Héctor Gálvez
 
All_About_Strings.pptxxbsnsnsmsmsmmmsmsmsm
All_About_Strings.pptxxbsnsnsmsmsmmmsmsmsmAll_About_Strings.pptxxbsnsnsmsmsmmmsmsmsm
All_About_Strings.pptxxbsnsnsmsmsmmmsmsmsm
kumarsahil80682
 
BCSE101E_Python_Module5 (4).pdf
BCSE101E_Python_Module5 (4).pdfBCSE101E_Python_Module5 (4).pdf
BCSE101E_Python_Module5 (4).pdf
mukeshb0905
 
unit-5 String Math Date Time AI presentation
unit-5 String Math Date Time AI presentationunit-5 String Math Date Time AI presentation
unit-5 String Math Date Time AI presentation
MukeshTheLioner
 
Web Application Development using PHP Chapter 3
Web Application Development using PHP Chapter 3Web Application Development using PHP Chapter 3
Web Application Development using PHP Chapter 3
Mohd Harris Ahmad Jaal
 
Advance topics of C language
Advance  topics of C languageAdvance  topics of C language
Advance topics of C language
Mehwish Mehmood
 

More from vishal choudhary (20)

Pixel to Percentage conversion Convert left and right padding of a div to per...
Pixel to Percentage conversion Convert left and right padding of a div to per...Pixel to Percentage conversion Convert left and right padding of a div to per...
Pixel to Percentage conversion Convert left and right padding of a div to per...
vishal choudhary
 
esponsive web design means that your website (
esponsive web design means that your website (esponsive web design means that your website (
esponsive web design means that your website (
vishal choudhary
 
function in php using like three type of function
function in php using  like three type of functionfunction in php using  like three type of function
function in php using like three type of function
vishal choudhary
 
data base connectivity in php using msql database
data base connectivity in php using msql databasedata base connectivity in php using msql database
data base connectivity in php using msql database
vishal choudhary
 
software evelopment life cycle model and example of water fall model
software evelopment life cycle model and example of water fall modelsoftware evelopment life cycle model and example of water fall model
software evelopment life cycle model and example of water fall model
vishal choudhary
 
software Engineering lecture on development life cycle
software Engineering lecture on development life cyclesoftware Engineering lecture on development life cycle
software Engineering lecture on development life cycle
vishal choudhary
 
OPEN SOURCE WEB APPLICATION DEVELOPMENT question
OPEN SOURCE WEB APPLICATION DEVELOPMENT  questionOPEN SOURCE WEB APPLICATION DEVELOPMENT  question
OPEN SOURCE WEB APPLICATION DEVELOPMENT question
vishal choudhary
 
web performnace optimization using css minification
web performnace optimization using css minificationweb performnace optimization using css minification
web performnace optimization using css minification
vishal choudhary
 
web performance optimization using style
web performance optimization using styleweb performance optimization using style
web performance optimization using style
vishal choudhary
 
Data types and variables in php for writing and databse
Data types and variables in php for writing  and databseData types and variables in php for writing  and databse
Data types and variables in php for writing and databse
vishal choudhary
 
Data types and variables in php for writing
Data types and variables in php for writingData types and variables in php for writing
Data types and variables in php for writing
vishal choudhary
 
Data types and variables in php for writing
Data types and variables in php for writingData types and variables in php for writing
Data types and variables in php for writing
vishal choudhary
 
sofwtare standard for test plan it execution
sofwtare standard for test plan it executionsofwtare standard for test plan it execution
sofwtare standard for test plan it execution
vishal choudhary
 
Software test policy and test plan in development
Software test policy and test plan in developmentSoftware test policy and test plan in development
Software test policy and test plan in development
vishal choudhary
 
function in php like control loop and its uses
function in php like control loop and its usesfunction in php like control loop and its uses
function in php like control loop and its uses
vishal choudhary
 
introduction to php and its uses in daily
introduction to php and its uses in dailyintroduction to php and its uses in daily
introduction to php and its uses in daily
vishal choudhary
 
data type in php and its introduction to use
data type in php and its introduction to usedata type in php and its introduction to use
data type in php and its introduction to use
vishal choudhary
 
PHP introduction how to create and start php
PHP introduction how to create and start phpPHP introduction how to create and start php
PHP introduction how to create and start php
vishal choudhary
 
SE-Lecture1.ppt
SE-Lecture1.pptSE-Lecture1.ppt
SE-Lecture1.ppt
vishal choudhary
 
SE-Testing.ppt
SE-Testing.pptSE-Testing.ppt
SE-Testing.ppt
vishal choudhary
 
Pixel to Percentage conversion Convert left and right padding of a div to per...
Pixel to Percentage conversion Convert left and right padding of a div to per...Pixel to Percentage conversion Convert left and right padding of a div to per...
Pixel to Percentage conversion Convert left and right padding of a div to per...
vishal choudhary
 
esponsive web design means that your website (
esponsive web design means that your website (esponsive web design means that your website (
esponsive web design means that your website (
vishal choudhary
 
function in php using like three type of function
function in php using  like three type of functionfunction in php using  like three type of function
function in php using like three type of function
vishal choudhary
 
data base connectivity in php using msql database
data base connectivity in php using msql databasedata base connectivity in php using msql database
data base connectivity in php using msql database
vishal choudhary
 
software evelopment life cycle model and example of water fall model
software evelopment life cycle model and example of water fall modelsoftware evelopment life cycle model and example of water fall model
software evelopment life cycle model and example of water fall model
vishal choudhary
 
software Engineering lecture on development life cycle
software Engineering lecture on development life cyclesoftware Engineering lecture on development life cycle
software Engineering lecture on development life cycle
vishal choudhary
 
OPEN SOURCE WEB APPLICATION DEVELOPMENT question
OPEN SOURCE WEB APPLICATION DEVELOPMENT  questionOPEN SOURCE WEB APPLICATION DEVELOPMENT  question
OPEN SOURCE WEB APPLICATION DEVELOPMENT question
vishal choudhary
 
web performnace optimization using css minification
web performnace optimization using css minificationweb performnace optimization using css minification
web performnace optimization using css minification
vishal choudhary
 
web performance optimization using style
web performance optimization using styleweb performance optimization using style
web performance optimization using style
vishal choudhary
 
Data types and variables in php for writing and databse
Data types and variables in php for writing  and databseData types and variables in php for writing  and databse
Data types and variables in php for writing and databse
vishal choudhary
 
Data types and variables in php for writing
Data types and variables in php for writingData types and variables in php for writing
Data types and variables in php for writing
vishal choudhary
 
Data types and variables in php for writing
Data types and variables in php for writingData types and variables in php for writing
Data types and variables in php for writing
vishal choudhary
 
sofwtare standard for test plan it execution
sofwtare standard for test plan it executionsofwtare standard for test plan it execution
sofwtare standard for test plan it execution
vishal choudhary
 
Software test policy and test plan in development
Software test policy and test plan in developmentSoftware test policy and test plan in development
Software test policy and test plan in development
vishal choudhary
 
function in php like control loop and its uses
function in php like control loop and its usesfunction in php like control loop and its uses
function in php like control loop and its uses
vishal choudhary
 
introduction to php and its uses in daily
introduction to php and its uses in dailyintroduction to php and its uses in daily
introduction to php and its uses in daily
vishal choudhary
 
data type in php and its introduction to use
data type in php and its introduction to usedata type in php and its introduction to use
data type in php and its introduction to use
vishal choudhary
 
PHP introduction how to create and start php
PHP introduction how to create and start phpPHP introduction how to create and start php
PHP introduction how to create and start php
vishal choudhary
 
Ad

Recently uploaded (20)

june 10 2025 ppt for madden on art science is over.pptx
june 10 2025 ppt for madden on art science is over.pptxjune 10 2025 ppt for madden on art science is over.pptx
june 10 2025 ppt for madden on art science is over.pptx
roger malina
 
Allomorps and word formation.pptx - Google Slides.pdf
Allomorps and word formation.pptx - Google Slides.pdfAllomorps and word formation.pptx - Google Slides.pdf
Allomorps and word formation.pptx - Google Slides.pdf
Abha Pandey
 
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition OecdEnergy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
razelitouali
 
Module 4 Presentation - Enhancing Competencies and Engagement Strategies in Y...
Module 4 Presentation - Enhancing Competencies and Engagement Strategies in Y...Module 4 Presentation - Enhancing Competencies and Engagement Strategies in Y...
Module 4 Presentation - Enhancing Competencies and Engagement Strategies in Y...
GeorgeDiamandis11
 
Adam Grant: Transforming Work Culture Through Organizational Psychology
Adam Grant: Transforming Work Culture Through Organizational PsychologyAdam Grant: Transforming Work Culture Through Organizational Psychology
Adam Grant: Transforming Work Culture Through Organizational Psychology
Prachi Shah
 
Ray Dalio How Countries go Broke the Big Cycle
Ray Dalio How Countries go Broke the Big CycleRay Dalio How Countries go Broke the Big Cycle
Ray Dalio How Countries go Broke the Big Cycle
Dadang Solihin
 
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKANMATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
aditya23173
 
Final Sketch Designs for poster production.pptx
Final Sketch Designs for poster production.pptxFinal Sketch Designs for poster production.pptx
Final Sketch Designs for poster production.pptx
bobby205207
 
Respiratory System , Urinary System
Respiratory  System , Urinary SystemRespiratory  System , Urinary System
Respiratory System , Urinary System
RushiMandali
 
Unit 3 Poster Sketches with annotations.pptx
Unit 3 Poster Sketches with annotations.pptxUnit 3 Poster Sketches with annotations.pptx
Unit 3 Poster Sketches with annotations.pptx
bobby205207
 
How to Manage Maintenance Request in Odoo 18
How to Manage Maintenance Request in Odoo 18How to Manage Maintenance Request in Odoo 18
How to Manage Maintenance Request in Odoo 18
Celine George
 
MATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKANMATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKAN
aditya23173
 
Pfeiffer "Secrets to Changing Behavior in Scholarly Communication: A 2025 NIS...
Pfeiffer "Secrets to Changing Behavior in Scholarly Communication: A 2025 NIS...Pfeiffer "Secrets to Changing Behavior in Scholarly Communication: A 2025 NIS...
Pfeiffer "Secrets to Changing Behavior in Scholarly Communication: A 2025 NIS...
National Information Standards Organization (NISO)
 
How to Manage & Create a New Department in Odoo 18 Employee
How to Manage & Create a New Department in Odoo 18 EmployeeHow to Manage & Create a New Department in Odoo 18 Employee
How to Manage & Create a New Department in Odoo 18 Employee
Celine George
 
Hemiptera & Neuroptera: Insect Diversity.pptx
Hemiptera & Neuroptera: Insect Diversity.pptxHemiptera & Neuroptera: Insect Diversity.pptx
Hemiptera & Neuroptera: Insect Diversity.pptx
Arshad Shaikh
 
BUSINESS QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 9 SEPTEMBER 2024
BUSINESS QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 9 SEPTEMBER 2024BUSINESS QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 9 SEPTEMBER 2024
BUSINESS QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 9 SEPTEMBER 2024
Quiz Club of PSG College of Arts & Science
 
What is FIle and explanation of text files.pptx
What is FIle and explanation of text files.pptxWhat is FIle and explanation of text files.pptx
What is FIle and explanation of text files.pptx
Ramakrishna Reddy Bijjam
 
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdfFEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
ChristinaFortunova
 
SEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptx
SEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptxSEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptx
SEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptx
PoojaSen20
 
Exploring Ocean Floor Features for Middle School
Exploring Ocean Floor Features for Middle SchoolExploring Ocean Floor Features for Middle School
Exploring Ocean Floor Features for Middle School
Marie
 
june 10 2025 ppt for madden on art science is over.pptx
june 10 2025 ppt for madden on art science is over.pptxjune 10 2025 ppt for madden on art science is over.pptx
june 10 2025 ppt for madden on art science is over.pptx
roger malina
 
Allomorps and word formation.pptx - Google Slides.pdf
Allomorps and word formation.pptx - Google Slides.pdfAllomorps and word formation.pptx - Google Slides.pdf
Allomorps and word formation.pptx - Google Slides.pdf
Abha Pandey
 
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition OecdEnergy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
razelitouali
 
Module 4 Presentation - Enhancing Competencies and Engagement Strategies in Y...
Module 4 Presentation - Enhancing Competencies and Engagement Strategies in Y...Module 4 Presentation - Enhancing Competencies and Engagement Strategies in Y...
Module 4 Presentation - Enhancing Competencies and Engagement Strategies in Y...
GeorgeDiamandis11
 
Adam Grant: Transforming Work Culture Through Organizational Psychology
Adam Grant: Transforming Work Culture Through Organizational PsychologyAdam Grant: Transforming Work Culture Through Organizational Psychology
Adam Grant: Transforming Work Culture Through Organizational Psychology
Prachi Shah
 
Ray Dalio How Countries go Broke the Big Cycle
Ray Dalio How Countries go Broke the Big CycleRay Dalio How Countries go Broke the Big Cycle
Ray Dalio How Countries go Broke the Big Cycle
Dadang Solihin
 
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKANMATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
aditya23173
 
Final Sketch Designs for poster production.pptx
Final Sketch Designs for poster production.pptxFinal Sketch Designs for poster production.pptx
Final Sketch Designs for poster production.pptx
bobby205207
 
Respiratory System , Urinary System
Respiratory  System , Urinary SystemRespiratory  System , Urinary System
Respiratory System , Urinary System
RushiMandali
 
Unit 3 Poster Sketches with annotations.pptx
Unit 3 Poster Sketches with annotations.pptxUnit 3 Poster Sketches with annotations.pptx
Unit 3 Poster Sketches with annotations.pptx
bobby205207
 
How to Manage Maintenance Request in Odoo 18
How to Manage Maintenance Request in Odoo 18How to Manage Maintenance Request in Odoo 18
How to Manage Maintenance Request in Odoo 18
Celine George
 
MATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKANMATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKAN
aditya23173
 
How to Manage & Create a New Department in Odoo 18 Employee
How to Manage & Create a New Department in Odoo 18 EmployeeHow to Manage & Create a New Department in Odoo 18 Employee
How to Manage & Create a New Department in Odoo 18 Employee
Celine George
 
Hemiptera & Neuroptera: Insect Diversity.pptx
Hemiptera & Neuroptera: Insect Diversity.pptxHemiptera & Neuroptera: Insect Diversity.pptx
Hemiptera & Neuroptera: Insect Diversity.pptx
Arshad Shaikh
 
What is FIle and explanation of text files.pptx
What is FIle and explanation of text files.pptxWhat is FIle and explanation of text files.pptx
What is FIle and explanation of text files.pptx
Ramakrishna Reddy Bijjam
 
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdfFEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
ChristinaFortunova
 
SEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptx
SEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptxSEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptx
SEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptx
PoojaSen20
 
Exploring Ocean Floor Features for Middle School
Exploring Ocean Floor Features for Middle SchoolExploring Ocean Floor Features for Middle School
Exploring Ocean Floor Features for Middle School
Marie
 
Ad

strings in php how to use different data types in string

  • 4. Single Quoted • The simplest way to create a string is to enclose the string literal (i.e. string characters) in single quotation marks ('), like this:
  • 5. Double-quote strings • Unlike single-quote strings, double-quote strings in PHP are capable of processing special characters.
  • 9. We can perform several functions on string in PHP . The string manipulation functions are.
  • 10. PHP Strings A string is a sequence of characters, like "Hello world!". we will look at some commonly used functions to manipulate strings. strlen() - Return the Length of a String The PHP strlen() function returns the length of a string.
  • 11. str_word_count() - Count Words in a String The PHP str_word_count() function counts the number of words in a string.
  • 12. strrev() - Reverse a String The PHP strrev() function reverses a string.
  • 13. trim() function: • This function allows us to remove whitespaces or strings from both sides of a string.
  • 15. str_replace() - Replace Text Within a String The PHP str_replace() function replaces some characters with some other characters in a string.
  • 16. strtolower() function: • This function converts a string into the lowercase string.
  • 17. strtoupper() function: • This function converts a string into the uppercase string.
  • 20. Comparing Strings The strcmp() function compares two strings. The strcmp() function is binary-safe and case-sensitive.
  • 21. Cleaning Strings The trim() function removes whitespace and other predefined characters from both sides of a string. Related functions: •ltrim() - Removes whitespace or other predefined characters from the left side of a string •rtrim() - Removes whitespace or other predefined characters from the right side of a string
  • 24. chop() Function • The chop() function is used to remove whitespace or other predefined character from the right end of a string. • Syntax: chop(string,charlist); • Example <?php $str = "Hello World!"; echo "Your string is :".$str."<br>"; echo "By using 'chop()' Functions is your string is: ".chop($str,"World!"); ?> Parameter Description Required/Optional string the string to be check Required charlist charlist parameter is empty Optional Output: Your string is :Hello World! By using 'chop()' Functions is your string is: Hello
  • 25. PHP chunk_split() Function • PHP chunk_split() function is used to splits a string into smaller parts or chunks. The function does not alter the original string. • Syntax: chunk_split(string,length,end) <?php $str = "Hello!; echo "Your string is:".$str; echo "By using 'chunk_split()' function your string is:".chunk_split($str,1,". .."); ?> Parameter Description Required/Optional string String to split Required Length Specify the length of the chunks. Default is 76 Optional end Specify what to place at the end each chunk. Optional Output: Your string is: Hello By using 'chunk_split()' function your string is: H…e...l...l...o...!...
  • 26. PHP type casting • Type casting allows you to convert a value of one type to another. To cast a value, you use the following type casting operators:
  • 27. Which of the following functions is used to find the first occurrence of a substring in a string? • strlen() • strpos() • str_replace() • str_split()
  • 28. Which of the following functions is used to find the first occurrence of a substring in a string? • strlen() • strpos() • str_replace() • str_split()
  • 29. Which of the following functions is used to replace all occurrences of a substring in a string with another substring? • strlen() • strpos() • str_replace() • str_split()
  • 30. Which of the following functions is used to replace all occurrences of a substring in a string with another substring? • strlen() • strpos() • str_replace() • str_split()
  • 31. Which of the following functions is used to count the number of words in a string? • strlen() • strpos() • str_replace() • str_word_count()
  • 32. Which of the following functions is used to count the number of words in a string? • strlen() • strpos() • str_replace() • str_word_count()
  • 33. Which of the following is not a built-in PHP function for working with strings? • strlen() • strpos() • str_replace() • str_split() • strrev()
  • 34. Which of the following is not a built-in PHP function for working with strings? • strlen() • strpos() • str_replace() • str_split() • strrev()
  • 35. What is the following is the output of the following PHP code? • • $str = "Hello, world!"; • echo strlen($str); • 13
  • 36. What is the following is the output of the following PHP code? • <?php • $str = "Hello, world!"; • echo strpos($str, "world"); • ?> • 7
  • 37. What is the following is the output of the following PHP code? • <?php • $str = "Hello, world!"; • echo str_replace("world", "universe", $str); • ?> • Hello universe
  • 38. What is the following is the output of the following PHP code? • <?php • $str = "Hello, world!"; • echo $str[0]; • ?> • H