Compdigitec Labs

« | Home | »

Determine the OS and version of PHP

By admin | July 16, 2008

It is very hard to determine the OS of the server/computer that is running PHP. So therefore here are two very, very useful methods to get the OS and Version of PHP.
This finds the version and OS the PHP on your server, not that person that is visiting your site.

To get the version of PHP, use phpversion(), a hidden function in PHP. However, your OS maker may have customized this so it may not be a pure number. For example, on Ubuntu Linux it returns 5.2.4-2ubuntu5.1, but on a Windows binary from php.net it returns 5.2.5, which is a pure number.

And to get the OS of PHP, use the hidden constant PHP_OS. If it doesn’t work, you could also try the following, even though the chances are very unlikely:

$_ENV['OS']
$_SERVER['OS']
$_SERVER['SERVER_SOFTWARE'] // The OS Info may be in there

If you found this article helpful or interesting, please help Compdigitec spread the word. Don’t forget to subscribe to Compdigitec Labs for more useful and interesting articles!

Topics: PHP | 13 Comments »

13 Responses to “Determine the OS and version of PHP”

  1. ddfr.ru Says:
    January 15th, 2025 at 04:05

    ddfr.ru

    ddfr.ru

  2. imkor.ru Says:
    January 15th, 2025 at 13:52

    imkor.ru

    imkor.ru

  3. Доставка авто з США Says:
    January 20th, 2025 at 04:39

    … [Trackback]

    […] Read More Info here on that Topic: compdigitec.com/labs/2008/07/16/determine-the-os-and-version-of-php/ […]

  4. altogel Says:
    January 22nd, 2025 at 22:20

    … [Trackback]

    […] Find More Info here to that Topic: compdigitec.com/labs/2008/07/16/determine-the-os-and-version-of-php/ […]

  5. edu-url-http.ru Says:
    January 23rd, 2025 at 12:55

    edu-url-http.ru

    edu-url-http.ru

  6. Free-Proxy-socks5-socks4.ru Says:
    January 24th, 2025 at 11:01

    Free-Proxy-socks5-socks4.ru

    Free-Proxy-socks5-socks4.ru

  7. Infographics Says:
    January 24th, 2025 at 19:32

    … [Trackback]

    […] Read More here on that Topic: compdigitec.com/labs/2008/07/16/determine-the-os-and-version-of-php/ […]

  8. iu0000ytre Says:
    January 24th, 2025 at 20:27

    iu0000ytre

    iu0000ytre

  9. fox888 Says:
    January 25th, 2025 at 11:24

    … [Trackback]

    […] Find More on that Topic: compdigitec.com/labs/2008/07/16/determine-the-os-and-version-of-php/ […]

  10. sitnikov Says:
    January 25th, 2025 at 16:34

    sitnikov

    sitnikov

  11. dilts.g-u.su Says:
    February 3rd, 2025 at 17:43

    dilts.g-u.su

    dilts.g-u.su

  12. xblx.ru Says:
    February 18th, 2025 at 14:26

    xblx.ru

    xblx.ru

  13. r2f.ru Says:
    February 18th, 2025 at 17:20

    r2f.ru

    r2f.ru

Comments