简体   繁体   中英

Help me understand this PHP code

I am a PHP beginner.

When going through a PHP script I found:

if(preg_match('/(?i)ID=(\d+)/',$input)) {
    // id found
}

I want to know what does (?i) mean ?

(?i) is a in line modifier which makes the match case insensitive.

It is equivalent to adding a i after the closing delimiter:

if(preg_match('/ID=(\d+)/i',$input))
                         ^

The below line is finding matching pattern in $input string like ID=any number.

preg_match('/ID=(\d+)/i',$input)

Example matching patterns are ID=2 id=34 Id=23

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM