CodeIgniter User Agent Configuration Arrays | Generated by AI

Home 2025.10

Overview

This PHP code snippet is part of the CodeIgniter framework (a PHP web framework), specifically from the User Agent Class configuration file. It defines four arrays ($platforms, $browsers, $mobiles, and $robots) that map user agent string fragments to human-readable names for browsers, operating systems, mobile devices, and web crawlers/bots. The code is used to parse and identify the type of device, browser, or bot visiting a website based on the HTTP User-Agent header sent by clients.

The arrays are associative (key-value pairs), where keys are partial strings from user agent strings (case-insensitive matches), and values are the corresponding display names. CodeIgniter’s User Agent library uses these for detection, such as determining if a visitor is on Android, using Chrome, or is a search bot.

$platforms Array

This array identifies operating systems or platforms. The keys are substrings that might appear in the User-Agent header, and values are clean names for display.

$browsers Array

Identifies web browsers. Browsers often report multiple identifiers, so the order prioritizes subtypes first (as per the comment).

$mobiles Array

Maps user agent flags for mobile devices, phones, and related devices/browsers. It’s larger and includes phones, tablets, game consoles, and fallback categories.

$robots Array

Lists common web crawlers and bots. Keys are substrings from bot user agents.

Usage in CodeIgniter

Additional Notes

If you provide a specific part or have a question about implementation, let me know!


Back

x-ai/grok-code-fast-1

Donate