Check if PHP is installed on Apache or IIS Server?

后端 未结 5 1914
心在旅途
心在旅途 2020-12-10 02:35

Is there a way to check if PHP is installed on an Apache or IIS server within the PHP environment itself?

If so, how?

5条回答
  •  南方客
    南方客 (楼主)
    2020-12-10 03:15

    The virtually most definitive answer possible (there are other similar possibilities) is:

    function on_iis() {
        $sSoftware = strtolower( $_SERVER["SERVER_SOFTWARE"] );
        if ( strpos($sSoftware, "microsoft-iis") !== false )
            return true;
        else
            return false;
    }
    

    Now, just use on_iis() whenever you want to know.

提交回复
热议问题