
stristr() 函数用于搜索一个字符串在另一个字符串中第一次出现的位置。
注意 - 该函数不区分大小写
语法stristr(str, search, before_search)
str - 要搜索的字符串
search - 要搜索的字符串
立即学习“PHP免费学习笔记(深入)”;
before_search - 一个布尔值,默认值为“false”。如果设置为“true”,则返回第一次出现搜索参数之前的字符串部分。
stristr()函数返回匹配的子字符串。
以下是示例 -
实时演示
<?php
$mystr = 'Tom Hanks!';
if(stristr($mystr, 'Tim') === FALSE) {
echo 'Tim is not in the string!';
}
?>Tim is not in the string!
以下是示例 -
现场演示
<?php
echo stristr("Demo text!","TEXT",true);
?>Demo
以上就是PHP中的stristr()函数的详细内容,更多请关注php中文网其它相关文章!
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号