# Global Variables

> Source: https://manual.pvxplus.com/apache/globalvar

The Global variables loaded by this interface are listed below.

Note:  
These variables are loaded by the PxPlus CGI handler (pxp_cgi), which is used by *both* the Apache HTTP interface and the [EZWeb Server](https://manual.pvxplus.com/ezwebserver/ezweb-introduction). They are therefore available to programs run under either server.  
  
Where a variable's value or availability differs under EZWeb Server, the difference is noted for that variable in the table below.

|  |  |  |
| --- | --- | --- |
| **Global Variable** | **Description** | **Apache Environment Value** |
| **%args$ \[ \]** | This string array will contain all the arguments passed to the program from the original URL/Query request. This array is one based. |  |
| **%args** | This numeric variable contains the number of arguments within the array %args$. |  |
| **%body_content$** | This variable will contain the complete contents of the body of the request as received from the workstation. | \<raw input> |
| **%cache_control$** | Value returned in the **Cache-Control** response header. If left blank, no Cache-Control header is sent. |  |
| **%content_filename$** | If set to a file name (no path), a **Content-Disposition:** attachment header is returned, prompting the browser to download ("Save As") the response using this file name. |  |
| **%content_length** | This variable contains the length of %body_content$ (length of body text as received from the browser workstation). | CONTENT_LENGTH |
| **%content_type$** | This variable will contain the type of contents received from the browser. | CONTENT_TYPE |
| **%cookie.rcv** | Number of cookies that were received from the workstation with the request. |  |
| **%cookie.snd** | This variable is set initially to zero and will be incremented by the \*web/cookie to track the number of cookies that will be downloaded to the workstation. |  |
| **%document_root$** | This will have the root directory as provided by the 'DocumentRoot' directive in the Apache configuration. Generally, this will be where the server files reside.<br>***Example:***<br>%DOCUMENT_ROOT$="/var/www/myweb/html"<br>Note:  <br>Under EZWeb Server, this is the EZWeb root/working directory rather than an Apache DocumentRoot. | DOCUMENT_ROOT |
| **%document_url$** | Actual URL being processed. | REDIRECT_URL |
| **%exit_code** | HTTP status code returned to the browser for this request. Typically 200 ("OK").<br>Assign a value to force a specific code. A value of 300 or greater triggers redirect or error handling. Valid codes include:<br>200 - OK  <br> 201 - Created  <br> 202 - Accepted  <br> 204 - No Content  <br> 300 - Multiple Choices  <br> 301 - Moved Permanently  <br> 302 - Moved Temporarily  <br> 304 - Not Modified  <br> 307 - Temporary Redirect  <br> 400 - Bad Request  <br> 401 - Unauthorized  <br> 403 - Forbidden  <br> 404 - Not Found  <br> 500 - Internal Server Error  <br> 501 - Not Implemented  <br> 502 - Bad Gateway  <br> 503 - Service Unavailable |  |
| **%exit_include_html** | When set together with an **%exit_code** of 300 or greater, the output sent to **%print_fn** is returned to the browser instead of the generic error message page.<br>Often used to return additional error information or JSON detailing the problem.<br>*(The %exit_include_html variable was added in PxPlus 2021.)* |  |
| **%exit_text$** | Status reason text returned with **%exit_code**. If left blank, it is filled automatically from the standard text for that status code. |  |
| **%expires$** | Value returned in the **Expires** response header. If left blank, a default (past) expiry date is sent; otherwise, the supplied value is used. |  |
| **%ezweb_log$** | ***(EZWeb Server Only)***<br>Path of the EZWeb access log. Not set under the Apache interface. |  |
| **%http_accept$** | This field will contain the MIME types that the requesting browser will accept according to the HTTP header. | HTTP_ACCEPT |
| **%http_accept_encoding$** | This contains the types of MIME encoding that the requesting browser will accept according to the HTTP header. | HTTP_ACCEPT_ENCODING |
| **%http_accept_language$** | This field will have the LANGUAGE types browser is requesting the server to supply.<br>***Example:***<br>%HTTP_ACCEPT_LANGUAGE$="en-us" | HTTP_ACCEPT_LANGUAGE |
| **%http_cookie$** | This variable will contain the string defining the cookies received from the workstation. Each cookie will be *semi-colon* separated. | HTTP_COOKIE |
| **%http_extraheaders$** | This variable can be loaded by the application with additional HTTP headers to be returned with the Web page. Each header should be separated by $0A$ or the SEP character.<br>*(The %http_extraheaders$ variable was added in PxPlus v11.00.)* |  |
| **%http_host$** | The Host header supplied by the browser for this request (distinct from **%server_name$**). | HTTP_HOST |
| **%http_user_agent$** | This field contains the type of browser or requesting program. | HTTP_USER_AGENT |
| Note:  <br>The %http\*$ list is illustrative: any inbound HTTP request header is exposed as a matching %HTTP\_*\<name>*$ variable (e.g. %HTTP_REFERER$). |  |  |
| **%lang$** | Language code to use for application (this is hard-coded to ".en"). |  |
| **%new_location$** | Redirect target URL.<br>To force the browser to request another URL, set **%new_location$** to that URL and set **%exit_code** to 301 (or 302/303/307). ***Both must be set.***<br>Returned as the Location header. |  |
| **%path_translated$** | Pathname to the target file that the request was looking for. | PATH_TRANSLATED |
| **%path_info$** | This field contains the relative pathname. | PATH_INFO |
| **%print_fn** | Logical file number to which your application should print (send) the HTML response.<br>When not running in Debug mode and cookies disabled, this will be 0 *(zero)*; otherwise, it will point to a memory file that holds the output pending transmission to the workstation. |  |
| **%query_string$** | Parameters following the "?" in the URL for this request. | QUERY_STRING |
| **%raw_text** | **0** = Output sent to the browser as is.  <br> **1** = Wrap an HTML header/body around the output from the PxPlus application. |  |
| **%remote_ip$** | Remote workstation/browser IP address. | REMOTE_ADDR |
| **%request_method$** | Type of HTTP request being processed; i.e. "POST", "GET" or "HEAD". | REQUEST_METHOD |
| **%script_name$** | This field will contain the file name of the CGI Script relative to DOCUMENT_ROOT directory. | SCRIPT_NAME |
| **%server_address$** | Server IP address plus port number. | SERVER_ADDR"+":"+"SERVER_PORT" |
| **%server_admin$** | Email address for the system administrator as defined in the Apache configuration file.<br>Note:  <br>Not available under EZWeb Server (no administrator configuration); will be empty. | SERVER_ADMIN |
| **%server_ip$** | Server IP address. | SERVER_ADDR |
| **%server_name$** | Server name as extracted from the HTTP request. | SERVER_NAME |
| **%server_port$** | Server port number as a string. **%server_port** is the same value as a number. | SERVER_PORT |
| **%server_protocol$** | Type and version of protocol being used for the request (HTTP/1.1, etc...). | SERVER_PROTOCOL |
| **%server_rootdir$** | Document root directory. |  |
| **%server_secure** | Set to 1 when the request was received over HTTPS; otherwise, 0. | HTTPS |
| **%server_software$** | Name of the server and associate software as reported to the browser.<br>Note:  <br>Under EZWeb Server, this is "EzWeb/Server". | SERVER_SOFTWARE |
| **%text_title$** | Title used for the generated HTML page when **%raw_text**=1. |  |
