php - Detect if the link has video extension (.avi or .mpg etc..) return false -


i need check if link normal page or video befor passed file_get_contents

because if link video page wait until whole video code

and don't need video code anyway

this example of code

//$foourl = "foofoo.com/page.html"; //$foourl = "foofoo.com/video.mpg"; //$foourl = "foofoo.com/video.avi";  if($foourl == ???){     echo "this video not normal page"; }else{     file_get_contents($foourl); } 

you can use regular expression:

if(preg_match('/.*\.(:?mpg|avi)/', $foourl)){     echo "this video not normal page";     ... 

add appropriate extensions if necessary: (:?mpg|avi|mp4) etc.


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -