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

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

主站蜘蛛池模板: 佳木斯市| 武功县| 上高县| 靖州| 云霄县| 革吉县| 大石桥市| 乌拉特前旗| 化隆| 安康市| 宁陵县| 依兰县| 康平县| 英吉沙县| 西林县| 西城区| 宁德市| 嘉黎县| 白山市| 三门峡市| 三台县| 乌鲁木齐县| 城市| 汾阳市| 星座| 礼泉县| 宿松县| 海兴县| 九寨沟县| 建阳市| 合川市| 遵化市| 清苑县| 邹平县| 花垣县| 定兴县| 灵石县| 金平| 桐庐县| 玛沁县| 宁武县|