Home > Backend Development > PHP Tutorial > How to use php strpos function

How to use php strpos function

藏色散人
Release: 2023-04-05 06:40:02
Original
3899 people have browsed it

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

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)
Copy after login

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");
?>
Copy after login

Output:

9
Copy after login

php strpos() function usage example 2:

<?php
var_dump(strpos("You love php, I love php too!","PHP")) ;
?>
Copy after login

Output:

bool(false)
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template