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

RSS Icon Subscribe to comments

You need to login to post a comment.