prova ad usare $_SERVER['HTTP_USER_AGENT'] al posto di $HTTP_USER_AGENT.