{server:variable}

Description

Returns the value of a PHP $_SERVER variable as a string. Pass the variable name - for example REMOTE_ADDR for the visitor IP address, HTTP_HOST for the requested host name, or REQUEST_URI for the path and query string of the current request. The output is whatever the web server placed in that entry of the $_SERVER superglobal, so it depends entirely on the request and the server configuration and is never cached. If the named variable is not set, the result is an empty string. Common uses are reading the client address (often combined with gethostbyaddr for a reverse-DNS host name), detecting the current host to build absolute links or enforce a canonical domain, and inspecting the request path. Because the value reflects the live request, treat every server lookup as runtime-dependent - the same template can print different values for different visitors. See the PHP manual for the full list of $_SERVER keys.

Parameters

variable required default (none - you must name a variable)

The name of the PHP $_SERVER entry to read, for example REMOTE_ADDR, HTTP_HOST, REQUEST_URI, or REQUEST_METHOD. The value is returned as a string exactly as the web server set it. If the named entry does not exist, the result is an empty string. Any $_SERVER key is accepted - see the allowed values below for the most useful ones and the PHP manual for the complete list.

Allowed values Any $_SERVER key is accepted. The most useful ones: REMOTE_ADDR (visitor IP address), HTTP_HOST (requested host name), REQUEST_URI (path and query string of the request), QUERY_STRING (query string without the leading question mark), HTTPS (non-empty when the request used HTTPS), SERVER_NAME (host name from the server configuration), HTTP_USER_AGENT (browser User-Agent), HTTP_REFERER (page that linked here, if sent), REQUEST_METHOD (GET, POST, and so on). See the PHP manual for the full list.

Examples

test[{server:THIS_KEY_DOES_NOT_EXIST}]
Expected[]
Actual[]
When the named $_SERVER entry is not set, the command returns an empty string. The square brackets here are literal text to make the empty result visible; they are not part of the syntax.
virtual{server:REMOTE_ADDR}
Expected84.42.240.38
Actual216.73.217.87
REMOTE_ADDR is the IP address of the client making the request. The value depends on the visitor, so this is illustrative, not a fixed test.
virtual{server:HTTP_HOST}
Expectedactionapps.org
Actualactionapps.org
HTTP_HOST is the host name from the request Host header. Useful for building absolute links or telling environments apart. Depends on how the page was reached.
virtual{server:REQUEST_URI}
Expected/aadev/view.php?vid=143
Actual/expression/server
REQUEST_URI is the path and query string of the current request. Depends on the URL being viewed.
virtual{gethostbyaddr:{server:REMOTE_ADDR}}
Expectedstatic-84-42-240-38.bb.vodafone.cz
Actual216.73.217.87
The canonical pairing: read the client IP with server, then resolve it to a host name with gethostbyaddr. Both the IP and its DNS name are runtime-dependent.
virtual{ifeq:{server:HTTP_HOST}:actionapps.org:live site:other host}
Expectedlive site
Actuallive site
Compare the current host with ifeq to switch behaviour per environment - here it prints "live site" only on actionapps.org. The same test guards a canonical-domain redirect in production: {redirect:{ifeq:{server:HTTP_HOST}:www.example.org::https://www.example.org{go}}} sends visitors on any other host to the canonical one. Output depends on the host, so this is illustrative.