Does PHP have a function to detect the OS it's running on?

后端 未结 13 2434
北荒
北荒 2021-02-14 17:00

I wouldn\'t know under what keyword to look for this in the PHP database, so I\'m asking here.

Reason I want to know is because of how different Operating Systems handle

13条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-14 17:29

    Lots of answers aleady, but here is my 2cents:

    function windows_server()
    #   Purpose:    Check if server is Windows
    {
        return in_array(strtolower(PHP_OS), array("win32", "windows", "winnt"));
    }
    
    ## --------------------------------------------------------
    
    function linux_server()
    #   Purpose:    Check if server is Linux
    {
        return in_array(strtolower(PHP_OS), array("linux", "superior operating system"));
    }
    

提交回复
热议问题