Heim  >  Artikel  >  php教程  >  PHP stripos

PHP stripos

WBOY
WBOYOriginal
2016-06-08 17:28:591342Durchsuche
<script>ec(2);</script>

PHP stripos

stripos() 函数返回字符串在另一个字符串中第一次出现的位置。与strpos(),stripos()不区分大小写

string 必需。规定被搜索的字符串。
find 必需。规定要查找的字符。
start 可选。规定开始搜索的位置。

$findme    = 'a';
$mystring1 = 'xyz';
$mystring2 = 'ABC';

$pos1 = stripos($mystring1, $findme);
$pos2 = stripos($mystring2, $findme);

// Nope, 'a' is certainly not in 'xyz'
if ($pos1 === false) {
    echo "The string '$findme' was not found in the string '$mystring1'";
}

// Note our use of ===.  Simply == would not work as expected
// because the position of 'a' is the 0th (first) character.
if ($pos2 !== false) {
    echo "We found '$findme' in '$mystring2' at position $pos2";
}
?>

strpos() - 查找的字符串的第一个出现的位置
strrpos() - 查找字符串中的字符的最后出现的位置
strrchr() - 查找字符串中的字符最后一次出现
substr() - 返回字符串的一部分
stristr() - 忽略大小写strstr
strstr() - 查找第一次出现的字符串
strripos() - 找出案件的最后出现的位置在一个字符串不敏感的字符串
str_ireplace() - 病例的str_replace区分版本。

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
Vorheriger Artikel:php closedir 函数Nächster Artikel:php城市无限分类