You cannot put "strings" inside a character class. Character classes work with characters , not strings. A character class can match only one of several characters.
So, the following regular expression:
/[\.gif$\.png$\.bmp$\.jpg$\.jpeg$]/
[ ]. , , \. - . , , .
:

. , (foo|bar) foo bar. :
/\.(gif|png|bmp|jpe?g)$/
, . , - ( URL):
$ext = pathinfo($url, PATHINFO_EXTENSION);