Skip to main content

Detect Whether Running under Windows or Not in PHP

In PHP, PHP_OS constant or php_uname method will result WIN32, WININT, or Windows. So, you can check first 3 letters.

if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
    echo 'This is a server using Windows!';
}

Comments