Date post: | 03-Apr-2018 |
Category: |
Documents |
Upload: | iwan-saputra |
View: | 226 times |
Download: | 0 times |
of 16
7/28/2019 String in Php
1/16
F5224
WEB PROGRAMMING
STRING IN PHP
ENVIRONMENT
Prepared by: Munirah Abd
7/28/2019 String in Php
2/16
PHP StringIntroduction-
The string functions allow you to manipulate strings.
A string variable is used to store and manipulatetext.
7/28/2019 String in Php
3/16
strlen() function
The strlen() function returns the length of a string.
DEFINITION & USAGE
strlen(string)
SYNTAX
7/28/2019 String in Php
4/16
strlen() function
Parameter Descriptionstring Required. Specifies the
string to check
7/28/2019 String in Php
5/16
strlen() function
EXAMPLE
12
OUTPUT
7/28/2019 String in Php
6/16
strpos() function
The strpos() function finds the position of the last occurrence of a string
inside another string.
This function returns the position on success, otherwise it returns FALSE.
DEFINITION & USAGE
strpos(string,find,start)
SYNTAX
7/28/2019 String in Php
7/16
strpos() function
Parameter Descriptionstring Required. Specifies the string to
searchfind Required. Specifies the string to
findstart Optional. Specifies where to
begin the search
7/28/2019 String in Php
8/16
strpos() function
EXAMPLE
6
OUTPUT
7/28/2019 String in Php
9/16
strstr() function
The strstr() function searches for the first occurrence of a string inside
another string.
This function returns the rest of the string (from the matching point), orFALSE, if the string to search for is not found.
DEFINITION & USAGE
strstr(string,search)SYNTAX
7/28/2019 String in Php
10/16
strstr() function
Parameter Description
string Required. Specifies the string tosearch
search Required. Specifies the string tosearch for. If this parameter is a
number, it will search for thecharacter matching the ASCII
value of the number
7/28/2019 String in Php
11/16
strstr() function
EXAMPLE 1
world!
OUTPUT
7/28/2019 String in Php
12/16
substr() function
The substr() function returns a part of a string.
DEFINITION & USAGE
substr(string,start,length)
SYNTAX
7/28/2019 String in Php
13/16
substr() function
Parameter Descriptionstring Required. Specifies the string to return a part ofstart Required. Specifies where to start in the stringA
positive number - Start at a specified position in
the string
A negative number - Start at a specified
position from the end of the string
0 - Start at the first character in stringlength Optional. Specifies the length of the returned
string. Default is to the end of the string.A
positive number - The length to be returned
from the start parameter
Negative number - The length to be returned
from the end of the string
7/28/2019 String in Php
14/16
substr() function
EXAMPLE 1
world!
OUTPUT
7/28/2019 String in Php
15/16
substr() function
EXAMPLE 2
world
OUTPUT
7/28/2019 String in Php
16/16
THE END