Search

Laravel Miscellaneous Helper Function: windows_os

November 21, 2016 —John Koster

windows_os

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®.

Using this function you can write code like so:

1<?php
2 
3if (windows_os()) {
4 // Windows® specific commands or instructions.
5} else {
6 // Anything that is not Windows®.
7}

instead of code like this:

1<?php
2 
3if (strtolower(substr(PHP_OS, 0, 3)) === 'win') {
4 // Windows&reg; specific commands or instructions.
5} else {
6 // Anything that is not Windows&reg;.
7}

Some absolutely amazing
people

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.