PTM Logo Version 0.5.1 Beta
Home    SVN    Downloads    Documentation    Forum    Contact
This Site is 100%
Powered by PTM

SourceForge.net Logo
Documentation
I   Index
II   GNU GPL
III   Description
IV   Installation
V   Language Overview
VI   Tags
VII   Variables
  • $_BASE
  • $_CGI
  • %_COOKIES
  • $_DEFAULT_PTM_FILE
  • $_DOCUMENT_ROOT
  • %_GET
  • $_HEADER
  • @_KEYWORDS
  • $_PATH
  • %_POST
  • @_PTM
  • $_PTM_POS
  • $_PTM_PREPROCESS
  • @_REQUIRE
  • $_SCRIPT
  • %_SERVER
  • %_SESSION
  • %_SET_COOKIES
  • $_SYNTAX_...
  • $_URL
  • $_USE_SECURE_SCRIPT_PASSING
  • $_VERSION
VIII   Functions
IX   Modules
Documentation
View / Download this file.
-----------------
%_SERVER VARIABLE
-----------------

  -----------
  DESCRIPTION
  -----------

    The implementation of PTM's %_SERVER variable is entirely dependent on the
    circumstances under which your PTM script is being run. %_SERVER is actually
    just a PTM port of Perl's %ENV variable, with a 'REQUEST_TIME' value added.
    So, depending on how your PTM script is being accessed (via the web or
    command line) %_SERVER will store a seperate set of values. However, since
    'REQUEST_TIME' is added by PTM at run-time, it will always be included.
    Because PTM was originally designed for web use with Apache, those values
    will be used for usage examples here. In the case of a web-access PTM script
    evaluation, %_SERVER stores information like HTTP host, server port,
    server protocol, server software, redirect status, document root, etc. Visit
    Apache.org to get a list of environment variables it creates, or use the PTM
    Test file that comes with every PTM installation package to see a full list
    of %_SERVER values.

    %_SERVER is structured similar to the following:

      %_SERVER = (
        REQUEST_TIME    => time(),
        REQUEST_METHOD  => 'GET',
        SERVER_PORT     => '80',
        ...etc...
      );

    The %_SERVER keys (environment variable names) can be accessed as a list
    (array) with Perl's "keys" command like so:

      @var_names = keys %_SERVER;

    The environment variable values can be accessed by referencing the specific
    name of the requested variable:

      $var_value = $_SERVER{'REQUEST_TIME'};

    Notice that, when referencing a specific variable value, the '%' is changed
    to a '$' when referencing the hash, as you are referencing a specific value
    and not the entire hash.

  --------------
  USAGE EXAMPLES
  --------------

    -----------------------------------------------------------------------
    Example 1: Showing the Value of a Server Variable using the DISPLAY Tag
    -----------------------------------------------------------------------

      The value of REQUEST_TIME is <?= $_SERVER{'REQUEST_TIME'} ?>.

    ------------------------------------------------------------------------
    Example 2: Showing All the Vars using the DO and DISPLAY Tags and a Loop
    ------------------------------------------------------------------------

      <? foreach $var (keys %_SERVER) { ?>
        The value of <?= $var ?> is <?= $_SERVER{$var} ?>.<br>
      <? } ?>

  --------
  SEE ALSO
  --------

    TAGS

      DO, DISPLAY

    VARIABLES

      $_DOCUMENT_ROOT, %_GET
Home    SVN    Downloads    Documentation    Forum    Contact