Heim  >  Artikel  >  Backend-Entwicklung  >  php strpos函数有什么用

php strpos函数有什么用

PHPz
PHPzOriginal
2016-06-13 10:11:162126Durchsuche

php strpos函数有什么用

php strpos函数有什么用?

定义和用法

strpos() f函数查找字符串在另一字符串中第一次出现的位置(区分大小写)。

注释:strpos() 函数是区分大小写的。

注释:该函数是二进制安全的。

相关函数:

strrpos() - 查找字符串在另一字符串中最后一次出现的位置(区分大小写)

stripos() - 查找字符串在另一字符串中第一次出现的位置(不区分大小写)

strripos() -查找字符串在另一字符串中最后一次出现的位置(不区分大小写)

语法

strpos(string,find,start)

参数 

string 必需。规定被搜索的字符串。

find 必需。规定要查找的字符。

start 可选。规定开始搜索的位置。

技术细节

返回值: 返回字符串在另一字符串中第一次出现的位置,如果没有找到字符串则返回 FALSE。注释: 字符串位置从 0 开始,不是从 1 开始。

实例

查找 "php" 在字符串中第一次出现的位置:

<?php
echo strpos("I love php, I love php too!","php");
?>

运行结果:

7

更多相关技术文章,请访问PHP中文网

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn