php check if given string is a file extension code example Example: php get file extension from filename $ext = pathinfo($filename, PATHINFO_EXTENSION);