MsO MsO - 1 year ago 173
PHP Question

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 application/x-javascript

and my way verify application/javascript and text/javascript.

Answer Source

Your current answer is:


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 quite useful for your experiments.