色尼玛亚洲综合影院,亚洲3atv精品一区二区三区,麻豆freexxxx性91精品,欧美在线91

php下使用strpos需要注意 === 運算符

復制代碼 代碼如下:
<?php
/*
判斷字符串是否存在的函數
*/
function strexists($haystack, $needle) {
return !(strpos($haystack, $needle) === FALSE);//注意這里的"==="
}
/*
Test
*/
$mystring = 'abc';
$findme = 'a';
$pos = strpos($mystring, $findme);

// Note our use of ===. Simply == would not work as expected
// because the position of 'a' was the 0th (first) character.
// 簡單的使用 "==" 號是不會起作用的,需要使用 "===",因為 a 第一次出現的位置為 0
if ($pos === false) {
echo "The string '$findme' was not found in the string '$mystring'";
} else {
echo "The string '$findme' was found in the string '$mystring'";
echo " and exists at position $pos";
}

// We can search for the character, ignoring anything before the offset
// 在搜索字符的時候可以使用參數 offset 來指定偏移量
$newstring = 'abcdef abcdef';
$pos = strpos($newstring, 'a', 1); // $pos = 7, not 0
?>

php技術php下使用strpos需要注意 === 運算符,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 浑源县| 平南县| 莱西市| 怀柔区| 临猗县| 寻乌县| 岳西县| 农安县| 藁城市| 科技| 古蔺县| 山阴县| 色达县| 安庆市| 宾川县| 洛川县| 额敏县| 雷波县| 来安县| 波密县| 武乡县| 虞城县| 瓦房店市| 安康市| 康乐县| 红桥区| 鹿邑县| 太谷县| 千阳县| 临沂市| 临桂县| 公主岭市| 庆云县| 汉源县| 乐安县| 景洪市| 蕉岭县| 广南县| 枞阳县| 陇南市| 本溪|