April 15, 2018 —John Koster
The windows_os
helper function can be used to determine if the host server is running a Microsoft Windows® operating system. The function returns either true
—if the server is running Windows®—or false
—if the server is not running Windows®.
The signature of the windows_os
function is:
1function windows_os();
Using this function you can write code like so:
1<?php2 3if (windows_os()) {4 // Windows® specific commands or instructions.5} else {6 // Anything that is not Windows®.7}
instead of code like this:
1<?php2 3if (strtolower(substr(PHP_OS, 0, 3)) === 'win') {4 // Windows® specific commands or instructions.5} else {6 // Anything that is not Windows®.7}
∎
The following amazing people help support this site and my open source projects ♥️
If you're interesting in supporting my work and want to show up on this list, check out my GitHub Sponsors Profile.