北京网帮你
php函数stripos方法不区分大小写,查找字符串首次出现的位置
时间:2018-06-29 03:28:01 浏览:230

如果未发现 needle,stripos() 将返回布尔型 FALSE。

Warning
此函数可能返回布尔值 FALSE,但也可能返回等同于 FALSE 的非布尔值,例如 0 或 ""(空串)。请阅读 布尔类型章节以获取更多信息。应使用 === 运算符 来测试此函数的返回值。

范例

Example #1 stripos() 范例

<?php
$findme    = 'a';
$mystring1 = 'xyz';
$mystring2 = 'ABC';

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

// 'a' 当然不在 'xyz' 中
if ($pos1 === false) {
   echo "The string '$findme' was not found in the string '$mystring1'";
}

// 注意这里使用的是 ===。简单的 == 不能像我们期望的那样工作,
// 因为 'a' 的位置是 0(第一个字符)。
if ($pos2 !== false) {
   echo "We found '$findme' in '$mystring2' at position $pos2";
}
?>

[上一篇]SEO日常问题百度每更新一次,网站
[下一篇]postgresql是什么,它和其它数据库
Copyright 2022 © 93580.com.cn 网帮你

2022 © 版权所有 红花岗区网帮你信息技术工作室

工信部备案号:黔ICP备2024036985号-2

请使用网帮你微信扫码登录