Check If Viewed Through Mobile
On many occasions, you may want to check if the current visitor is browsing your site through a mobile browser. There are a lot of solutions out there (classes, libraries), but the simplest option has been working fine for me for years.