php - Determine whether current script is running on development or production server -


i've got scripts call different urls depending on if they're processed online site (release), or offline localhost (development). i'd find quick way find which.

i can come few clunky ways this, there definitive, fast, elegant method? if(is_offline()) { ... }

  1. a variable called $_server["computername"] available on iis servers, can use determine if script running on development server or production server (mymachine vs. www37).

  2. you can use $_server["http_host"] variable (localhost vs. www.domain.com).

  3. you can create empty text file on development server (careful not upload it) , use is_file() check if presence (is_file(".foo") == true vs. false).

  4. you can check php_os if operating systems on 2 servers different (winnt vs. linux).

  5. you can check presence of path inside __file__ constant (c:/inetpub/wwwroot/website/ vs. /home/www37/).

  6. a variant of 3: @include("override_server_with_local_config.php");


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -