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
Ad

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)

YSPH VMOC Special Report - Measles Outbreak Southwest US 4-30-2025.pptx
YSPH VMOC Special Report - Measles Outbreak  Southwest US 4-30-2025.pptxYSPH VMOC Special Report - Measles Outbreak  Southwest US 4-30-2025.pptx
YSPH VMOC Special Report - Measles Outbreak Southwest US 4-30-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
Introduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe EngineeringIntroduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe Engineering
Damian T. Gordon
 
apa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdfapa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdf
Ishika Ghosh
 
Presentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem KayaPresentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem Kaya
MIPLM
 
Sinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_NameSinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_Name
keshanf79
 
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
larencebapu132
 
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
Celine George
 
Political History of Pala dynasty Pala Rulers NEP.pptx
Political History of Pala dynasty Pala Rulers NEP.pptxPolitical History of Pala dynasty Pala Rulers NEP.pptx
Political History of Pala dynasty Pala Rulers NEP.pptx
Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
 
How to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odooHow to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odoo
Celine George
 
GDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptxGDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptx
azeenhodekar
 
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-3-2025.pptx
YSPH VMOC Special Report - Measles Outbreak  Southwest US 5-3-2025.pptxYSPH VMOC Special Report - Measles Outbreak  Southwest US 5-3-2025.pptx
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-3-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
Biophysics Chapter 3 Methods of Studying Macromolecules.pdf
Biophysics Chapter 3 Methods of Studying Macromolecules.pdfBiophysics Chapter 3 Methods of Studying Macromolecules.pdf
Biophysics Chapter 3 Methods of Studying Macromolecules.pdf
PKLI-Institute of Nursing and Allied Health Sciences Lahore , Pakistan.
 
Exploring-Substances-Acidic-Basic-and-Neutral.pdf
Exploring-Substances-Acidic-Basic-and-Neutral.pdfExploring-Substances-Acidic-Basic-and-Neutral.pdf
Exploring-Substances-Acidic-Basic-and-Neutral.pdf
Sandeep Swamy
 
Unit 6_Introduction_Phishing_Password Cracking.pdf
Unit 6_Introduction_Phishing_Password Cracking.pdfUnit 6_Introduction_Phishing_Password Cracking.pdf
Unit 6_Introduction_Phishing_Password Cracking.pdf
KanchanPatil34
 
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Library Association of Ireland
 
To study the nervous system of insect.pptx
To study the nervous system of insect.pptxTo study the nervous system of insect.pptx
To study the nervous system of insect.pptx
Arshad Shaikh
 
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public SchoolsK12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
dogden2
 
Social Problem-Unemployment .pptx notes for Physiotherapy Students
Social Problem-Unemployment .pptx notes for Physiotherapy StudentsSocial Problem-Unemployment .pptx notes for Physiotherapy Students
Social Problem-Unemployment .pptx notes for Physiotherapy Students
DrNidhiAgarwal
 
Quality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdfQuality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdf
Dr. Bindiya Chauhan
 
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - WorksheetCBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
Sritoma Majumder
 
Introduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe EngineeringIntroduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe Engineering
Damian T. Gordon
 
apa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdfapa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdf
Ishika Ghosh
 
Presentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem KayaPresentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem Kaya
MIPLM
 
Sinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_NameSinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_Name
keshanf79
 
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
larencebapu132
 
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
Celine George
 
How to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odooHow to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odoo
Celine George
 
GDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptxGDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptx
azeenhodekar
 
Exploring-Substances-Acidic-Basic-and-Neutral.pdf
Exploring-Substances-Acidic-Basic-and-Neutral.pdfExploring-Substances-Acidic-Basic-and-Neutral.pdf
Exploring-Substances-Acidic-Basic-and-Neutral.pdf
Sandeep Swamy
 
Unit 6_Introduction_Phishing_Password Cracking.pdf
Unit 6_Introduction_Phishing_Password Cracking.pdfUnit 6_Introduction_Phishing_Password Cracking.pdf
Unit 6_Introduction_Phishing_Password Cracking.pdf
KanchanPatil34
 
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Library Association of Ireland
 
To study the nervous system of insect.pptx
To study the nervous system of insect.pptxTo study the nervous system of insect.pptx
To study the nervous system of insect.pptx
Arshad Shaikh
 
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public SchoolsK12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
dogden2
 
Social Problem-Unemployment .pptx notes for Physiotherapy Students
Social Problem-Unemployment .pptx notes for Physiotherapy StudentsSocial Problem-Unemployment .pptx notes for Physiotherapy Students
Social Problem-Unemployment .pptx notes for Physiotherapy Students
DrNidhiAgarwal
 
Quality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdfQuality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdf
Dr. Bindiya Chauhan
 
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - WorksheetCBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
Sritoma Majumder
 
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