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 | 20 Comments »

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

  1. 100 tsitat velikikh lyudey Says:
    October 25th, 2026 at 03:26

    100 tsitat velikikh lyudey

    100 tsitat velikikh lyudey

  2. Psychoanalyst Says:
    October 25th, 2026 at 04:55

    Psychoanalyst

    Psychoanalyst

  3. Freid Says:
    October 25th, 2026 at 07:29

    Freid

    Freid

  4. yalta Says:
    October 28th, 2026 at 15:31

    yalta

    yalta

  5. เสากั้นทางเดิน Says:
    October 29th, 2026 at 03:19

    … [Trackback]

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

  6. psychologist Says:
    October 30th, 2026 at 03:02

    psychologist

    psychologist

  7. management Says:
    October 30th, 2026 at 14:25

    management

    management

  8. structure-of-legal-norms Says:
    October 30th, 2026 at 15:39

    structure-of-legal-norms

    structure-of-legal-norms

  9. Carl Gustav Jung Says:
    October 30th, 2026 at 16:12

    Carl Gustav Jung

    Carl Gustav Jung

  10. archive Says:
    October 31st, 2026 at 13:03

    archive

    archive

  11. Q141974782 Says:
    November 2nd, 2026 at 14:25

    Q141974782

    Q141974782

  12. psiholog-psiholog-onlajn Says:
    November 4th, 2026 at 17:32

    psiholog-psiholog-onlajn

    psiholog-psiholog-onlajn

  13. Single-Session Says:
    November 5th, 2026 at 03:56

    Single-Session

    Single-Session

  14. Online psychologist Says:
    November 6th, 2026 at 14:23

    Online psychologist

    Online psychologist

  15. Cognitive warfare Says:
    November 10th, 2026 at 07:54

    Cognitive warfare

    Cognitive warfare

  16. Cognitive Says:
    November 11th, 2026 at 04:14

    Cognitive

    Cognitive

  17. scholar Says:
    November 16th, 2026 at 05:13

    scholar

    scholar

  18. orcid Says:
    November 16th, 2026 at 16:04

    orcid

  19. post Says:
    November 16th, 2026 at 16:44

    post

    post

  20. doi Says:
    November 17th, 2026 at 02:16

    doi

    doi

Comments