I have a PHP script that may be placed on a windows system or a linux system. I need to run different commands in either case.
How can I detect which environment I am in? (preferably something PHP rather than clever system hacks)
Update
To clarify, the script is running from the command line.
\strncasecmp(\PHP_OS, 'WIN', 3) === 0,\strtoupper(\substr(\PHP_OS, 0, 3)) === 'WIN'and\stripos(\PHP_OS, 'WIN')are below 15%. Since all three solutions only take roughly 100 nanoseconds, this would be a micro-optimization, anyway. So choose whatever solution you like. Finally, you may argue that\strncasecmp(\PHP_OS, 'WIN', 3) === 0is the most readable.