Just no win-win situation

Yesterday I moved a PHP project from Windows to OS X. For reasons of laziness I often code something like:

if (stristr(PHP_OS, \”WIN\”)) {
echo \”Do something Windows-related here…\”;
}

This worked usually perfect for scripts moved between Windows and Linux based systems. But one has to be more precise for scripts to run additionally on OS X. Since OS X comes with a PHP_OS string consisting of \”Darwin\”. If you are wondering, why your scripts do not work on Mac try this:

if (stristr(PHP_OS, \”Windows\”)) {
echo \”Do something Windows-related here…\”;
}

Leave a Reply