irc-html                Wed Jan  9 22:09:49 2002 EDT

  Added files:                 
    /phpdoc/en/appendices       predefined.xml 
  Log:
  Incremental update for list of predefined variables and constants.  Please don't 
link or translate, just copied over the information from the chapter sections.
  

Index: phpdoc/en/appendices/predefined.xml
+++ phpdoc/en/appendices/predefined.xml
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.1 $ -->

<-- Note:  Please do not link or translate this file yet.
This is only an initial update, quite a few more commits will
follow for this appendix. -->

<appendix id="predefined">

 <title>List of Predefined Variables and Constants</title>
 <para>
  The following is a listing of predefined variables and 
  and constants.  These lists are neither exhaustive or complete.
 </para>
 
 <sect1 id="predefined.variables">
  <title>Listing of Predefined Variables</title>

   <sect2 id="predefined.variables.apache">
    <title>Apache variables</title>

    <simpara>
     These variables are created by the <ulink
     url="&url.apache;">Apache</ulink> webserver. If you are running
     another webserver, there is no guarantee that it will provide the
     same variables; it may omit some, or provide others not listed
     here. That said, a large number of these variables are accounted
     for in the <ulink url="&url.cgispec;">CGI 1.1
     specification</ulink>, so you should be able to expect those.
    </simpara>
    <simpara>
     Note that few, if any, of these will be available (or indeed have
     any meaning) if running PHP on the command line.
    </simpara>

    <para>
     <variablelist>
      <varlistentry>
       <term>$GATEWAY_INTERFACE</term>
       <listitem>
        <simpara>
         What revision of the CGI specification the server is using;
         i.e. 'CGI/1.1'.
        </simpara>
       </listitem>
      </varlistentry>

      <varlistentry>
       <term>$SERVER_NAME</term>
       <listitem>
        <simpara>
         The name of the server host under which the current script is
         executing. If the script is running on a virtual host, this
         will be the value defined for that virtual host.
        </simpara>
       </listitem>
      </varlistentry>

      <varlistentry>
       <term>$SERVER_SOFTWARE</term>
       <listitem>
        <simpara>
         Server identification string, given in the headers when
         responding to requests.
        </simpara>
       </listitem>
      </varlistentry>

      <varlistentry>
       <term>$SERVER_PROTOCOL</term>
       <listitem>
        <simpara>
         Name and revision of the information protocol via which the
         page was requested; i.e. 'HTTP/1.0';
        </simpara>
       </listitem>
      </varlistentry>
      
      <varlistentry>
       <term>$REQUEST_METHOD</term>
       <listitem>
        <simpara>
         Which request method was used to access the page; i.e. 'GET',
         'HEAD', 'POST', 'PUT'.
        </simpara>
       </listitem>
      </varlistentry>
          
      <varlistentry>
       <term>$QUERY_STRING</term>
       <listitem>
        <simpara>
         The query string, if any, via which the page was accessed.
        </simpara>
       </listitem>
      </varlistentry>

      <varlistentry>
       <term>$DOCUMENT_ROOT</term>
       <listitem>
        <simpara>
         The document root directory under which the current script is
         executing, as defined in the server's configuration file.
        </simpara>
       </listitem>
      </varlistentry>

      <varlistentry>
       <term>$HTTP_ACCEPT</term>
       <listitem>
        <simpara>
         Contents of the <literal>Accept:</literal> header from the
         current request, if there is one.
        </simpara>
       </listitem>
      </varlistentry>

      <varlistentry>
       <term>$HTTP_ACCEPT_CHARSET</term>
       <listitem>
        <simpara>
         Contents of the <literal>Accept-Charset:</literal> header
         from the current request, if there is one. Example:
         'iso-8859-1,*,utf-8'.
        </simpara>
       </listitem>
      </varlistentry>

      <varlistentry>
       <term>$HTTP_ACCEPT_ENCODING</term>
       <listitem>
        <simpara>
         Contents of the <literal>Accept-Encoding:</literal> header
         from the current request, if there is one. Example: 'gzip'.
        </simpara>
       </listitem>
      </varlistentry>
      
      <varlistentry>
       <term>$HTTP_ACCEPT_LANGUAGE</term>
       <listitem>
        <simpara>
         Contents of the <literal>Accept-Language:</literal> header
         from the current request, if there is one. Example: 'en'.
        </simpara>
       </listitem>
      </varlistentry>
      
      <varlistentry>
       <term>$HTTP_CONNECTION</term>
       <listitem>
        <simpara>
         Contents of the <literal>Connection:</literal> header from
         the current request, if there is one. Example: 'Keep-Alive'.
        </simpara>
       </listitem>
      </varlistentry>

      <varlistentry>
       <term>$HTTP_HOST</term>
       <listitem>
        <simpara>
         Contents of the <literal>Host:</literal> header from the
         current request, if there is one.
        </simpara>
       </listitem>
      </varlistentry>

      <varlistentry>
       <term>$HTTP_REFERER</term>
       <listitem>
        <simpara>
         The address of the page (if any) which referred the browser
         to the current page. This is set by the user's browser; not
         all browsers will set this.
        </simpara>
       </listitem>
      </varlistentry>

      <varlistentry>
       <term>$HTTP_USER_AGENT</term>
       <listitem>
        <simpara>
         Contents of the <literal>User_Agent:</literal> header from
         the current request, if there is one. This is a string
         denoting the browser software being used to view the current
         page; i.e. <computeroutput>Mozilla/4.5 [en] (X11; U; Linux
         2.2.9 i586)</computeroutput>. Among other things, you can use
         this value with <function>get_browser</function> to tailor
         your page's functionality to the capabilities of the user's
         browser.
        </simpara>
       </listitem>
      </varlistentry>

      <varlistentry>
       <term>$REMOTE_ADDR</term>
       <listitem>
        <simpara>
         The IP address from which the user is viewing the current
         page.
        </simpara>
       </listitem>
      </varlistentry>

      <varlistentry>
       <term>$REMOTE_PORT</term>
       <listitem>
        <simpara>
         The port being used on the user's machine to communicate with
         the web server.
        </simpara>
       </listitem>
      </varlistentry>

      <varlistentry>
       <term>$SCRIPT_FILENAME</term>
       <listitem>
        <simpara>
         The absolute pathname of the currently executing script.
        </simpara>
       </listitem>
      </varlistentry>

      <varlistentry>
       <term>$SERVER_ADMIN</term>
       <listitem>
        <simpara>
         The value given to the SERVER_ADMIN (for Apache) directive in
         the web server configuration file. If the script is running
         on a virtual host, this will be the value defined for that
         virtual host.
        </simpara>
       </listitem>
      </varlistentry>
      
      <varlistentry>
       <term>$SERVER_PORT</term>
       <listitem>
        <simpara>
         The port on the server machine being used by the web server
         for communication. For default setups, this will be '80';
         using SSL, for instance, will change this to whatever your
         defined secure HTTP port is.
        </simpara>
       </listitem>
      </varlistentry>

      <varlistentry>
       <term>$SERVER_SIGNATURE</term>
       <listitem>
        <simpara>
         String containing the server version and virtual host name
         which are added to server-generated pages, if enabled.
        </simpara>
       </listitem>
      </varlistentry>

      <varlistentry>
       <term>$PATH_TRANSLATED</term>
       <listitem>
        <simpara>
         Filesystem- (not document root-) based path to the current
         script, after the server has done any virtual-to-real
         mapping.
        </simpara>
       </listitem>
      </varlistentry>

      <varlistentry>
       <term>$SCRIPT_NAME</term>
       <listitem>
        <simpara>
         Contains the current script's path. This is useful for pages
         which need to point to themselves.
        </simpara>
       </listitem>
      </varlistentry>

      <varlistentry>
       <term>$REQUEST_URI</term>
       <listitem>
        <simpara>
         The URI which was given in order to access this page; for
         instance, '/index.html'.
        </simpara>
       </listitem>
      </varlistentry>
     </variablelist>
    </para>

   </sect2>

   <sect2 id="predefined.variables.environment">
    <title>Environment variables</title>

    <simpara>
     These variables are imported into PHP's global namespace from the
     environment under which the PHP parser is running. Many are
     provided by the shell under which PHP is running and different
     systems are likely running different kinds of shells, a
     definitive list is impossible. Please see your shell's
     documentation for a list of defined environment variables.
    </simpara>
    <simpara>
     Other environment variables include the CGI variables, placed
     there regardless of whether PHP is running as a server module or
     CGI processor.
    </simpara>
        
   </sect2>

   <sect2 id="predefined.variables.php">
    <title>PHP variables</title>
    
    <simpara>
     These variables are created by PHP itself. The
     <varname>$HTTP_*_VARS</varname> variables are available only if
     the <link linkend="ini.track-vars">track_vars</link>
     configuration is turned on. When enabled, the variables are
     always set, even if they are empty arrays. This prevents
     a malicious user from spoofing these variables.
    </simpara>

    <note>
     <para>
      As of PHP 4.0.3, <link
      linkend="ini.track-vars">track_vars</link> is always turned on,
      regardless of the configuration file setting.
     </para>
    </note>

    <para>
     If the <link
     linkend="ini.register-globals">register_globals</link> directive
     is set, then these variables will also be made available in the
     global scope of the script; i.e., separate from the
     <varname>$HTTP_*_VARS</varname> arrays. This feature should be
     used with care, and turned off if possible; while the
     <varname>$HTTP_*_VARS</varname> variables are safe, the bare
     global equivalents can be overwritten by user input, with
     possibly malicious intent. If you cannot turn off <link
     linkend="ini.register-globals">register_globals</link>, you must
     take whatever steps are necessary to ensure that the data you are
     using is safe.
    </para>
    
    <para>
     <variablelist>
      <varlistentry>
       <term>$argv</term>
       <listitem>
        <simpara>
         Array of arguments passed to the script. When the script is
         run on the command line, this gives C-style access to the
         command line parameters. When called via the GET method, this
         will contain the query string.
        </simpara>
       </listitem>
      </varlistentry>

      <varlistentry>
       <term>$argc</term>
       <listitem>
        <simpara>
         Contains the number of command line parameters passed to the
         script (if run on the command line).
        </simpara>
       </listitem>
      </varlistentry>

      <varlistentry>
       <term>$PHP_SELF</term>
       <listitem>
        <simpara>
         The filename of the currently executing script, relative to
         the document root. If PHP is running as a command-line
         processor, this variable is not available.
        </simpara>
       </listitem>
      </varlistentry>
          
      <varlistentry>
       <term>$HTTP_COOKIE_VARS</term>
       <listitem>
        <simpara>
         An associative array of variables passed to the current
         script via HTTP cookies. 
        </simpara>
       </listitem>
      </varlistentry>
      
      <varlistentry>
       <term>$HTTP_GET_VARS</term>
       <listitem>
        <simpara>
         An associative array of variables passed to the current
         script via the HTTP GET method.
        </simpara>
       </listitem>
      </varlistentry>
      
      <varlistentry>
       <term>$HTTP_POST_VARS</term>
       <listitem>
        <simpara>
         An associative array of variables passed to the current
         script via the HTTP POST method.
        </simpara>
       </listitem>
      </varlistentry>
    
      <varlistentry>
       <term>$HTTP_POST_FILES</term>
       <listitem>
        <simpara>
         An associative array of variables containing information
         about files uploaded via the HTTP POST method. See <link
         linkend="features.file-upload.post-method">POST method
         uploads</link> for information on the contents of
         <varname>$HTTP_POST_FILES</varname>.
        </simpara>
        <para>
         <varname>$HTTP_POST_FILES</varname> is available only in PHP
         4.0.0 and later.
        </para>
       </listitem>
      </varlistentry>
  
    <varlistentry>
       <term>$HTTP_ENV_VARS</term>
       <listitem>
        <simpara>
         An associative array of variables passed to the current
         script via the parent environment. 
        </simpara>
       </listitem>
      </varlistentry>

    <varlistentry>
       <term>$HTTP_SERVER_VARS</term>
       <listitem>
        <simpara>
         An associative array of variables passed to the current
         script from the HTTP server. These variables are analogous to
         the Apache variables described above.
        </simpara>
       </listitem>
      </varlistentry>
     </variablelist>
    </para>
        
   </sect2>

 </sect1>

 <sect1 id="predefined.constants">
  <title>Listing of Predefined Constants</title>
  <para>
   The predefined constants (always available) are:

   <variablelist>

    <varlistentry>
     <term>__FILE__  (case-insensitive)</term>
     <listitem>
      <simpara>
       The name of the script file presently being parsed. If used
       within a file which has been included or required, then the
       name of the included file is given, and not the name of the
       parent file.
      </simpara>
     </listitem>
    </varlistentry>
    
    <varlistentry>
     <term>__LINE__  (case-insensitive)</term>
     <listitem>
      <simpara>
       The number of the line within the current script file which is
       being parsed. If used within a file which has been included or
       required, then the position within the included file is given.
      </simpara>
     </listitem>
    </varlistentry>
    
    <varlistentry>
     <term>PHP_VERSION</term>
     <listitem>
      <simpara>
       The string representation of the version of the PHP parser
       presently in use; for example '4.1.0'.
      </simpara>
     </listitem>
    </varlistentry>
    
    <varlistentry>
     <term>PHP_OS</term>
     <listitem>
      <simpara>
       The name of the operating system on which the PHP parser is
       executing;. Possible values may be : 
       "AIX", "Darwin" (MacOS), "Linux", "SunOS", "WIN32", "WINNT".
       Note: other values may be available too.
      </simpara>
     </listitem>
    </varlistentry>
    
    <varlistentry>
     <term>&true;  (case-insensitive)</term>
     <listitem>
      <simpara>
       A &true; value (see the <type>boolean</type> type).
      </simpara>
     </listitem>
    </varlistentry>
    
    <varlistentry>
     <term>&false;  (case-insensitive)</term>
     <listitem>
      <simpara>
       A &false; value (see the <type>boolean</type> type).
      </simpara>
     </listitem>
    </varlistentry>
    
    <varlistentry>
     <term>&null;  (case-insensitive)</term>
     <listitem>
      <simpara>
       A &null; value (see the <type>null</type> type).
      </simpara>
     </listitem>
    </varlistentry>
    
    <varlistentry>
     <term>E_ERROR</term>
     <listitem>
      <simpara>
       Denotes an error other than a parsing error from which
       recovery is not possible. 
      </simpara>
     </listitem>
    </varlistentry>
    
    <varlistentry>
     <term>E_WARNING</term>
     <listitem>
      <simpara>
       Denotes a condition where PHP knows something is wrong, but
       will continue anyway; these can be caught by the script
       itself. An example would be an invalid regexp in
       <function>ereg</function>.
      </simpara>
     </listitem>
    </varlistentry>
    
    <varlistentry>
     <term>E_PARSE</term>
     <listitem>
      <simpara>
       The parser choked on invalid syntax in the script
       file. Recovery is not possible.
      </simpara>
     </listitem>
    </varlistentry>
    
    <varlistentry>
     <term>E_NOTICE</term>
     <listitem>
      <simpara>
       Something happened which may or may not be an error. Execution
       continues. Examples include using an unquoted string as an array
       index, or accessing a variable which has not been set.
      </simpara>
     </listitem>
    </varlistentry>
    
    <varlistentry>
     <term>E_ALL</term>
     <listitem>
      <simpara>
       All of the E_* constants rolled into one. If used with
       <function>error_reporting</function>, will cause any and all
       problems noticed by PHP to be reported.
      </simpara>
     </listitem>
    </varlistentry>

   </variablelist>
  </para>
 </sect1>

</appendix>

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->

Reply via email to