How to get user agent in PHP January 9, 2023 by Tarik Use the native PHP $_SERVER['HTTP_USER_AGENT'] variable instead.