Skip to content

Instantly share code, notes, and snippets.

@w3spi5
Last active March 10, 2024 17:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save w3spi5/508a1087b523b4f78910429d4bdd78ef to your computer and use it in GitHub Desktop.
Save w3spi5/508a1087b523b4f78910429d4bdd78ef to your computer and use it in GitHub Desktop.
PHP - One line static function to check if you are in local or prod env
<?php
public static function isLocal(): bool
{
return in_array($_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1']);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment