isApache() and isIIS() functions for PHP

A couple quick little functions for when you need to know if you're running on Apache or IIS.

PHP:
  1. function isApache()
  2.     {
  3.     return ((bool) preg_match('/Apache/i', $_SERVER['SERVER_SOFTWARE']));
  4.     }
  5. function isIIS()
  6.     {
  7.     return ((bool) preg_match('/IIS/i', $_SERVER['SERVER_SOFTWARE']));
  8.     }

isApache() will return true if it's running on an Apache server and false if not. isIIS() will do the same if it's running or not running on IIS.

Question, Comments...

Do you have more questions. Please either leave a comment below or join us in our new forum.

Leave a Reply