喝苦荞茶对身体有什么好处| 什么的粉墙| 7月30日是什么星座| 生肖狗和什么生肖相冲| 糖皮质激素是什么药| 空亡什么意思| 人为什么要洗澡| 不劳而获是什么生肖| 烫伤抹什么管用| 无期是什么意思| 唐人是什么意思| 6.29什么星座| 寻麻疹不能吃什么| 肾在什么位置| 按摩手推是什么意思| 母乳什么味道| 肠道菌群失调有什么症状| 血糖高不能吃什么| 脚后跟痒是什么原因| 身上很痒是什么原因| 梦见黑蛇是什么预兆| 十一月十七日是什么星座| 疝气长在什么位置图片| 月抛什么意思| 尿频是什么病| remember是什么意思| 5.3什么星座| 怀孕不到一个月有什么症状| 医是什么结构| 敏感肌是什么意思| 绿豆芽不能和什么一起吃| 朝鲜和韩国什么时候分开的| 三斤八两什么意思| 付之一炬是什么意思| 小腿肌肉抽筋是什么原因引起的| 似乎的近义词是什么| 尿结石是什么症状表现| 什么是股癣| 伤疤好了变黑了是什么原因| 劳苦功高是什么意思| 私募是做什么的| 照身份证穿什么颜色的衣服| 二椅子什么意思| 胃恶心想吐吃什么药| 怀孕吃什么必定流产| 寿司醋可以用什么代替| 女人的逼是什么意思| 苋菜与什么食物相克| 3月6号是什么星座的| 眼睛的晶体是什么| 排卵期有什么| 为什么鼻子无缘无故流鼻血| 睡觉流口水什么原因| 经常手麻是什么原因| 容易长痣是什么原因| 肉麻是什么意思| 猪心炖什么适合孩子| 妒忌什么意思| 慈禧属什么生肖| 嗓子发炎挂什么科| 垂体泌乳素高是什么原因| 血药浓度是什么意思| 边鱼是什么鱼| 惴惴不安什么意思| 属虎的是什么命| 梦到小鸟是什么意思| 生不如死什么意思| 什么睡姿对髋关节好| 正值当年什么意思| sorona是什么面料| 眼睛老跳是什么原因| 周六左眼跳是什么预兆| 梦到小男孩是什么意思| 扁桃体结石长什么样| 老是放屁什么原因| 白细胞高是什么原因引起的| 电镀是做什么的| lively是什么意思| 处男是什么| 孕妇查凝血是检查什么| 甘油三酯高吃什么| 歌姬是什么意思| 手指爆皮是什么原因| 造影检查对身体有什么伤害| 低脂是什么意思| 阴唇为什么会变黑| 全身发麻是什么原因引起的| 喝酒头疼吃什么药| cabbeen是什么牌子| 6.29是什么星座| 生肖蛇和什么生肖相冲| 眼睛浮肿什么原因| 无花果吃多了有什么坏处| 意大利用的什么货币| 10属什么| 吉祥是什么生肖| 半边脸肿是什么原因| emba是什么| 社交恐惧是什么| 软禁是什么意思| 淋巴细胞百分比偏高是什么意思| 早上喝豆浆有什么好处| 代偿期和失代偿期是什么意思| 肛瘘是什么症状| 无心是什么意思| 荔枝有什么作用与功效| 谷草谷丙偏高代表什么| 肠炎吃什么食物调理| 冥界是什么意思| 拔牙后吃什么消炎药最好| 有什么寓言故事| 发烧应该吃什么药| 物料是什么意思| 凌晨两点是什么时辰| 不可思议的意思是什么| 颈动脉斑块挂什么科| 女孩断掌纹代表什么| 高考450分能上什么学校| 湿疹是什么样的图片| 印尼用什么货币| 四月初十是什么星座| 急性肠胃炎是什么引起的| 剖腹产第三天可以吃什么| 雌二醇高有什么症状| 舅舅的女儿叫什么| 牙齿发炎吃什么药| 曹休和曹操什么关系| 体重下降是什么原因| 石榴石一般什么价位| 鼻子干燥吃什么中成药| ib是什么单位| 百合什么时候开花| 江苏属于什么方向| 十一是什么意思| 爱彼手表什么档次| 复刻鞋是什么意思| 蝴蝶吃什么食物| 血脂指的是什么| 金刚杵是什么| 妈妈是什么| 晨尿浑浊是什么原因| 长期咳白痰是什么原因| 送什么礼品好| 单侧耳鸣是什么原因引起的| 晚上咳嗽吃什么药| 来月经同房会有什么后果| 医院为什么禁止小孩灌肠| sancanal是什么牌子| 中国的国树是什么| 鸭肫是什么| 什么是牙结石| 红霉素软膏和红霉素眼膏有什么区别| 白血病是什么症状| 药物制剂是干什么的| 七月18日是什么星座| 淡奶油是什么| 原味是什么意思| a型血可以接受什么血型| 看望病人送什么花| 逆转是什么意思| 成手是什么意思| 无济于事的意思是什么| 献血有什么坏处| 速度等于什么| 傧相是什么意思| 黑色签字笔是什么笔| 梅艳芳什么病| 什么长什么短| 什么的摇篮| 老人怕冷是什么原因| 女性肾功能不好有什么症状| 头昏脑胀是什么原因| 属兔本命佛是什么佛| 喝什么茶叶对身体好| 经期吃榴莲有什么好处和坏处| 老汉推车是什么意思| 巴适什么意思| 什么是无产阶级| 1996年五行属什么| 骨关节响是什么原因| 什么远什么长| 属鸡女和什么属相最配| 尿带血是什么原因| 男人什么时候精子最强| 文化底蕴是什么意思| 牙疼吃什么水果好| 儿童遗尿挂什么科| 浑水摸鱼是什么意思| 正常高压是什么意思| 腹股沟淋巴结肿大挂什么科| tct和hpv有什么区别| 阻滞是什么意思| 人什么地灵| 过敏性咳嗽吃什么药好| 星辰大海什么意思| 钾偏低是什么原因| 低热吃什么药| 深深是什么意思| 食物中毒挂什么科| 功能性消化不良是什么意思| 74年属虎是什么命| 客厅用什么灯具好| 头皮挂什么科| 饸烙面是什么面| 事业有成是什么意思| 饱胀是什么意思| 咀嚼食用是什么意思| c1e驾照能开什么车| 梦见杀鸡是什么意思| 吃鹅蛋有什么好处和坏处| 什么可以变白皮肤| 什么是单亲家庭| 返聘是什么意思| 吃什么东西容易消化| 怀孕肚子痒是什么原因| 梦见找鞋子是什么意思| 脐动脉2条是什么意思| 农历是什么生肖| 河蟹吃什么| 海马是什么类动物| 反酸是什么意思| 腐竹是什么| 八方来财是什么意思| 什么发色显皮肤白| 阴茎疼是什么原因| 什么是理科什么是文科| 过路车是什么意思| 美容行业五行属什么| 因材施教什么意思| 情何以堪 什么意思| 俄罗斯被称为什么| 升学宴选什么日子好| 避免是什么意思| 十八反是什么意思| 6月16什么星座| 去湿气吃什么| 脚后跟疼痛什么原因| 过敏性鼻炎吃什么水果好| 1.9号是什么星座| 牛皮革是什么意思| hpv51阳性是什么意思| 耳鼻喉属于什么科| 为什么抽筋| 梦见自己理发是什么意思| 伏案工作是什么意思| 做梦梦见搬家是什么意思| knife是什么意思| 头发干燥是什么原因| 什么是经络| 维生素c什么时候吃效果最好| ein是什么牌子| 郝字五行属什么| 数是什么意思| 京东自营是什么意思| 什么是宫腔镜手术| 生命的本质是什么| 满月红鸡蛋用什么染| 什么鬼什么神| 眼白发蓝是什么原因| 2017年属鸡火命缺什么| 身上痒但是什么都没有| 高血压要吃什么| lp 什么意思| 9月3号是什么节日| 百度
rfc:str_icontains

弯弯的月亮像什么

Introduction

百度 在考核中,考核组对照《2016年度市直有关部门和单位安全生产工作考核细则》,对支队消防安全责任制落实、安全生产方针政策和法律法规宣贯、火灾隐患排查治理、部队应急救援、社会化消防宣传等工作台账资料进行了详细的检查,并逐一对检查情况进行了记录。

PHP 8.0 introduced the str_contains function, which provides a clear and concise way to determine if a string contains a given substring. This was a significant improvement over the traditional method of using strpos and checking the return value.

However, a common use case is to check for the presence of a substring in a case-insensitive manner. Currently, this requires using functions like stripos or converting both the haystack and needle to the same case using strtolower or strtoupper before comparison. These approaches can be less intuitive and more error-prone.

To address this, this RFC proposes the addition of a new function, str_icontains, as a case-insensitive counterpart to str_contains. The naming convention follows the precedent set by existing string functions, such as str_replace and its case-insensitive variant, str_ireplace.

Proposal

It is proposed to add a new function to PHP:

function str_icontains(string $haystack, string $needle): bool

This function will return true if $needle is found in $haystack, with the comparison performed in a case-insensitive manner. The case-insensitivity will be based on ASCII case folding, which means it will correctly handle standard English alphabet characters (a-z, A-Z). This is consistent with the behaviour of other case-insensitive string functions in PHP, such as str_ireplace and stripos.

Use Cases

Example 1: Basic Usage

$string = "The quick brown fox jumps over the lazy dog.";
 
str_icontains($string, 'fox'); // true
str_icontains($string, 'FOX'); // true
str_icontains($string, 'Fox'); // true

Example 2: Comparison with current methods

Without str_icontains, a developer would have to write:

// Using stripos
stripos($string, 'FOX') !== false; // true
 
// Using strtolower
str_contains(strtolower($string), strtolower('FOX')); // true

The proposed str_icontains function is more readable and less susceptible to errors.

Why wasn't this included with str_contains?

I have reviewed the previous discussions and RFCs surrounding the initial introduction of str_contains. The reason a case-insensitive version was not included at that time was twofold:

  • Limited Functional Gain: Some community members felt that the case-insensitive variant did not provide a significant enough improvement over existing userland code (e.g., strtolower($haystack)) to warrant its inclusion in the PHP core.
  • Risk of RFC Failure: The debate over whether to include a case-insensitive version, particularly with the complexities of ASCII vs. UTF-8 case folding, was a contentious topic that could have jeopardised the entire str_contains RFC from passing. The primary goal was to get a simple, much-needed function into the core.

Now that str_contains is a stable and widely used function in the PHP core, adding a case-insensitive version seems to me to be a logical next step. It creates a complete and consistent set of functions, mirroring the relationships between strpos -> stripos and strstr -> stristr. While the ASCII-only folding remains a limitation, this behaviour is consistent with its sibling functions, providing a predictable and familiar experience for developers.

Having a UTF-8 supported version of this suite of functions that matches on the lower/upper case variant of each Unicode code point should of course be a goal, but I believe the inclusion of this function in its current form, aligned with its siblings, is better than not having the function at all.

Backward Incompatible Changes

This RFC proposes the addition of a new function, so it does not introduce any backward-incompatible changes.

Proposed PHP Version(s)

Next PHP 8.x (8.5).

Proposed Voting Choices

Yes or no vote. 2/3 required to pass.

str_icontains
Real name Yes No
alec (alec)  
ashnazg (ashnazg)  
ayesh (ayesh)  
bwoebi (bwoebi)  
crell (crell)  
cschneid (cschneid)  
daniels (daniels)  
derick (derick)  
devnexen (devnexen)  
ericmann (ericmann)  
galvao (galvao)  
heiglandreas (heiglandreas)  
mfonda (mfonda)  
rasmus (rasmus)  
seld (seld)  
thorstenr (thorstenr)  
timwolla (timwolla)  
Final result: 6 11
This poll has been closed.

Patches and Tests

Implementation

After the project is implemented, this section should contain

  1. the version(s) it was merged into
  2. a link to the git commit(s)
  3. a link to the PHP manual entry for the feature
  4. a link to the language specification section (if any)

References

Rejected Features

UTF-8 Support

This RFC intentionally omits support for full UTF-8 case folding. The primary goal is to provide a direct, case-insensitive companion to the existing str_contains function, thereby achieving feature parity with other core string functions that operate on ASCII case folding (e.g., stripos, stristr). Introducing multibyte-aware functionality would be a significant extension beyond this scope and is better suited for a separate, more comprehensive proposal regarding multibyte string handling.

stri_contains Naming

The name str_icontains was chosen over stri_contains to maintain consistency with the precedent set by str_ireplace.

rfc/str_icontains.txt · Last modified: by adamcable

?
迷妹是什么意思 转基因是什么意思 什么人不能吃桃子 胃食管反流挂什么科 lynn是什么意思
伤食是什么意思 性向是什么意思 脂溢性脱发用什么洗发水好 天蝎是什么象星座 鱼头和什么搭配煲汤好
石榴花什么时候开 扭捏是什么意思 东南方是什么生肖 师兄是什么意思 医院规培生是什么意思
单纯性肥胖是什么意思 蒙脱石散是什么药 什么地什么 凌晨十二点是什么时辰 凤梨和菠萝的区别是什么
中国最毒的蛇是什么蛇hcv8jop9ns0r.cn 棕榈油是什么油hcv9jop4ns8r.cn 羊可以加什么偏旁hcv8jop5ns0r.cn 花生什么时候成熟hcv8jop2ns3r.cn 14数字代表什么意思liaochangning.com
茯苓的功效与作用是什么hcv9jop1ns1r.cn 117是什么意思hcv7jop9ns7r.cn 肛门瘙痒用什么药膏hcv7jop6ns8r.cn 肚子大了是什么原因造成的imcecn.com 8月份是什么星座hcv9jop7ns0r.cn
黄体期出血是什么原因hcv9jop3ns5r.cn 金钱龟吃什么食物1949doufunao.com 性向是什么意思hcv8jop6ns9r.cn 什么水果清热去火hcv8jop5ns3r.cn 孕妇为什么不能吃山楂hcv8jop4ns7r.cn
念珠菌是什么病hcv8jop3ns9r.cn 验孕棒ct分别代表什么yanzhenzixun.com 史记是什么体史书hcv8jop4ns2r.cn 做梦死人了是什么征兆hcv8jop6ns0r.cn 室性期前收缩是什么意思hcv8jop7ns3r.cn
百度