Hi there everyone!
PHP 8.3
To start, this is not code I use to make important decisions, like serving a mobile site or other. I just use this to fill out some additional stats on visitors for my own interest.
I wrote a short block to do this but not only does it look ugly, it seems to lack things that I might want in the future, for instance, instead of just "this", if "this" OR "that" is in the string, it's a match.
I'm wondering if you guys wouldn't mind looking at this and offering any suggestions to make it better.
// Platform check
$is_win = $is_lin = $is_android = $is_iphone = $is_ipad = $is_ios = $is_mobile = $is_tablet = $is_phone = '0';
if(str_contains(strtolower($_SERVER["HTTP_USER_AGENT"]), 'windows')){
$is_win = '1';
}elseif(str_contains(strtolower($_SERVER["HTTP_USER_AGENT"]), 'linux')){
$is_lin = '1';
}elseif(str_contains(strtolower($_SERVER["HTTP_USER_AGENT"]), 'ios')){
$is_android = '1';
}elseif(str_contains(strtolower($_SERVER["HTTP_USER_AGENT"]), 'android')){
$is_ios = '1';
}