PHP script - detect whether running under Linux or Windows or other Operating System? I don't have so much knowledge but can overcome with some solution. "PHP_OS" will solve this issue. Below is function to check if OS is Windows or not:
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
echo 'Windows!';
} else {
echo 'Other Than Windows!';
}
PHP_OS will output below list of Operating System, not full list but I think it's almost all.
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
echo 'Windows!';
} else {
echo 'Other Than Windows!';
}
PHP_OS will output below list of Operating System, not full list but I think it's almost all.
- CYGWIN_NT-5.1
- Darwin
- FreeBSD
- HP-UX
- IRIX64
- Linux
- NetBSD
- OpenBSD
- SunOS
- Unix
- WIN32
- WINNT
- Windows
No comments:
Post a Comment