色尼玛亚洲综合影院,亚洲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需要注意 === 運算符,轉載需保留來源!

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

主站蜘蛛池模板: 合江县| 苍山县| 鄂州市| 密山市| 来凤县| 札达县| 宁德市| 虹口区| 锡林郭勒盟| 桐梓县| 崇阳县| 来宾市| 新宾| 双辽市| 宁河县| 武安市| 旬阳县| 卢湾区| 南皮县| 长宁县| 东台市| 宜兰县| 盐津县| 夏津县| 巴林左旗| 孟村| 神池县| 内黄县| 乌海市| 大荔县| 司法| 望江县| 兴仁县| 莒南县| 龙海市| 孟村| 昌平区| 青田县| 水富县| 兰州市| 会东县|