Detect Dev or Prod environment


/ Published in: PHP
Save to your folder(s)

Will return "dev" when it detect those syntax in the hostname
dev.
.local
localhost
192.168


Copy this code and paste it in your HTML
  1. define('ENVIRONMENT', preg_match('/(dev\.)|(\.local)|(localhost)|(192\.168)/', $_SERVER["HTTP_HOST"]) ? "dev" : "prod");

Report this snippet


Comments


You need to login to view comments.