MsO MsO - 2 years ago 207
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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download