Home > Article > Backend Development > How to use php strpos function
PHP strpos function is used to find the first occurrence of a string. The syntax is strpos(string,find,start), the parameter string is required and specifies the string to be searched; find is required and specifies the string to be found.
How to use php strpos function?
php strpos() function syntax
Function: Find a string The first position where a certain character appears in
Syntax:
strpos(string,find,start)
Parameters:
string required. Specifies the string to search for.
findRequired. Specifies the string to search for.
start is optional. Specifies where to start the search.
Description:
Find the first occurrence of a string in another string. The strpos() function is case-sensitive. This function is binary safe.
php strpos() function usage example 1:
<?php echo strpos("You love php, I love php too!","php"); ?>
Output:
9
php strpos() function usage example 2:
<?php var_dump(strpos("You love php, I love php too!","PHP")) ; ?>
Output:
bool(false)
This article is an introduction to the PHP strpos function. I hope it will be helpful to friends in need!
The above is the detailed content of How to use php strpos function. For more information, please follow other related articles on the PHP Chinese website!