The substr operation expects minimum of two args ie the string and the start position, In light of this i think we can just leave it without the substr operation as strrchr gets the extension inclusive of the dot[.] thus no need for substr.

Thus the new change be $file_type = strrchr($filename,".");