php – Why does the User-Agent header always return "Mozilla /5.0" regardless of the browser?


I know that in PHP we can access a header called User-Agent and thus discover information about the operating system and browser used by the client.

The only thing I don't understand is that "Mozilla /5.0" always appears (even if I use a browser other than Firefox).




Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:39.0) Gecko/20100101 Firefox/39.0

This string above was returned from PHP. I was using Firefox 39.0 in my tests. However, if I did this with another browser, it would return "Mozilla/5.0"

So here are two questions (I'll be happy if only the first one is answered):

  • Why is this header returning the browser name, it also returns "Mozilla /5.0"? Is it something else that has nothing to do with Firefox?


This excellent article on the history of browsers explains a little about their history, and the excerpt below is the one that matters most for the context of the question:

(…) Mozilla built Gecko, and called itself Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.1) Gecko/20020826, and Gecko was the rendering engine, and Gecko was good. And Mozilla became Firefox, and called itself Mozilla/5.0 (Windows; U; Windows NT 5.1; sv-SE; rv:1.7.5) Gecko/20041108 Firefox/1.0, and Firefox was very good.

And Gecko began to multiply, and other browsers were born that used its code, and they called themselves Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.7.2) Gecko/20040825 Camino /0.8.1 the one, and Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv: Gecko/20071008 SeaMonkey/1.0 another, each pretending to be Mozilla, and all of them powered by Gecko.

Basically, Gecko (which is also called Mozilla/5.0) is the open-source rendering engine implemented by most browsers these days — that's why the user-agent string starts with Mozilla/5.0.

Scroll to Top