简体   繁体   中英

regex: Matching a javascript mime type in content-type http header

Looking for some way, I can verify the javascript content-type,
I have made

if(preg_match('/(text|application)\/javascript/i',$header){ #code ...

but this won't work all the cases because some servers reply with 回复
and my way verify and .

Your current answer is:

(text|application)\/(x-)?javascript

Will match x-javascript part too. Thats very small and basic change, I recommend you to study a bit more about regexp.
And you might find site regex101.com quite useful for your experiments.

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