PHP script – detect whether running under linux or Windows?

Check the value of the PHP_OS constantDocs.

It will give you various values on Windows like WIN32, WINNT or Windows.

See as well: Possible Values For: PHP_OS and php_unameDocs:

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

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)