⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mod_include.html

📁 这个是我在web培训时老师提供的手册
💻 HTML
📖 第 1 页 / 共 3 页
字号:
      </dd>
      </dl>
     

    <h3><a name="element.fsize" id="element.fsize">The fsize Element</a></h3>
      <p>This command prints the size of the specified file, subject
      to the <code>sizefmt</code> format specification. Attributes:</p>

      <dl>
      <dt><code>file</code></dt>
      <dd>The value is a path relative to the directory
      containing the current document being parsed.</dd>

      <dt><code>virtual</code></dt>
      <dd>The value is a (%-encoded) URL-path. If it does not begin with
      a slash (/) then it is taken to be relative to the current document.
      Note, that this does <em>not</em> print the size of any CGI output,
      but the size of the CGI script itself.</dd>
      </dl>
     

    <h3><a name="element.flastmod" id="element.flastmod">The flastmod Element</a></h3>
      <p>This command prints the last modification date of the
      specified file, subject to the <code>timefmt</code> format
      specification. The attributes are the same as for the
      <code><a href="#element.fsize">fsize</a></code> command.</p>
     

    <h3><a name="element.include" id="element.include">The include Element</a></h3>
      <p>This command inserts the text of another document or file
      into the parsed file. Any included file is subject to the usual
      access control. If the directory containing the parsed file has
      <a href="core.html#options">Options</a>
      <code>IncludesNOEXEC</code> set, then only documents with a text
      <a class="glossarylink" href="../glossary.html#mime-type" title="see glossary">MIME-type</a> (<code>text/plain</code>, <code>text/html</code> etc.) will be included. Otherwise CGI
      scripts are invoked as normal using the complete URL given in
      the command, including any query string.</p>

      <p>An attribute defines the location of the document; the
      inclusion is done for each attribute given to the include
      command. The valid attributes are:</p>

      <dl>
      <dt><code>file</code></dt>
      <dd>The value is a path relative to the directory
      containing the current document being parsed. It cannot
      contain <code>../</code>, nor can it be an absolute path.
      Therefore, you cannot include files that are outside of the
      document root, or above the current document in the directory
      structure. The <code>virtual</code> attribute should always be
      used in preference to this one.</dd>

      <dt><code><a id="includevirtual" name="includevirtual">virtual</a></code></dt>
      <dd><p>The value is a (%-encoded) URL-path. The URL cannot contain a
      scheme or hostname, only a path and an optional query string. If it
      does not begin with a slash (/) then it is taken to be relative to the
      current document.</p>

      <p>A URL is constructed from the attribute, and the output the
      server would return if the URL were accessed by the client is
      included in the parsed output. Thus included files can be nested.</p>

      <p>If the specified URL is a CGI program, the program will be
      executed and its output inserted in place of the directive in the
      parsed file. You may include a query string in a CGI url:</p>
     
      <div class="example"><p><code>
        &lt;!--#include virtual="/cgi-bin/example.cgi?argument=value" --&gt;
      </code></p></div>
           
      <p><code>include virtual</code> should be used in preference
      to <code>exec cgi</code> to include the output of CGI programs
      into an HTML document.</p>
      </dd>
      </dl>
     

    <h3><a name="element.printenv" id="element.printenv">The printenv Element</a></h3>
      <p>This prints out a listing of all existing variables and
      their values. Special characters are entity encoded (see the <code><a href="#element.echo">echo</a></code> element for details)
      before being output. There are no attributes.</p>

      <div class="example"><h3>示例</h3><p><code>
        &lt;!--#printenv --&gt;
      </code></p></div>
     

    <h3><a name="element.set" id="element.set">The set Element</a></h3>
      <p>This sets the value of a variable. Attributes:</p>

      <dl>
      <dt><code>var</code></dt>
      <dd>The name of the variable to set.</dd>

      <dt><code>value</code></dt>
      <dd>The value to give a variable.</dd>
      </dl>

      <div class="example"><h3>示例</h3><p><code>
        &lt;!--#set var="category" value="help" --&gt;
      </code></p></div>
     
</div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<div class="section">
<h2><a name="includevars" id="includevars">Include Variables</a></h2>
    

    <p>In addition to the variables in the standard CGI environment,
    these are available for the <code>echo</code> command, for
    <code>if</code>和<code>elif</code>, and to any program
    invoked by the document.</p>

    <dl>
      <dt><code>DATE_GMT</code></dt>
      <dd>The current date in Greenwich Mean Time.</dd>

      <dt><code>DATE_LOCAL</code></dt>
      <dd>The current date in the local time zone.</dd>

      <dt><code>DOCUMENT_NAME</code></dt>
      <dd>The filename (excluding directories) of the document
      requested by the user.</dd>

      <dt><code>DOCUMENT_URI</code></dt>
      <dd>The (%-decoded) URL path of the document requested by the
      user. Note that in the case of nested include files, this is
      <em>not</em> the URL for the current document.</dd>

      <dt><code>LAST_MODIFIED</code></dt>
      <dd>The last modification date of the document requested by
      the user.</dd>

      <dt><code>QUERY_STRING_UNESCAPED</code></dt>
      <dd>If a query string is present, this variable contains the
      (%-decoded) query string, which is <em>escaped</em> for shell
      usage (special characters like <code>&amp;</code> etc. are
      preceded by backslashes).</dd>
    </dl>
</div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<div class="section">
<h2><a name="substitution" id="substitution">Variable Substitution</a></h2>

    <p>Variable substitution is done within quoted strings in most
    cases where they may reasonably occur as an argument to an SSI
    directive. This includes the <code>config</code>, <code>exec</code>, <code>flastmod</code>, <code>fsize</code>, <code>include</code>, <code>echo</code>, and <code>set</code>
    directives, as well as the arguments to conditional operators.
    You can insert a literal dollar sign into the string using backslash
    quoting:</p>

    <div class="example"><p><code>
      &lt;!--#if expr="$a = \$test" --&gt;
    </code></p></div>

    <p>If a variable reference needs to be substituted in the
    middle of a character sequence that might otherwise be
    considered a valid identifier in its own right, it can be
    disambiguated by enclosing the reference in braces,
    <em>a la</em> shell substitution:</p>

    <div class="example"><p><code>
      &lt;!--#set var="Zed" value="${REMOTE_HOST}_${REQUEST_METHOD}" --&gt;
    </code></p></div>

    <p>This will result in the <code>Zed</code> variable being set
    to "<code>X_Y</code>" if <code>REMOTE_HOST</code> is
    "<code>X</code>" and <code>REQUEST_METHOD</code> is
    "<code>Y</code>".</p>

    <p>The below example will print "in foo" if the
    <code>DOCUMENT_URI</code> is <code>/foo/file.html</code>, "in bar"
    if it is <code>/bar/file.html</code> and "in neither" otherwise:</p>

    <div class="example"><p><code>
      &lt;!--#if expr='"$DOCUMENT_URI" = "/foo/file.html"' --&gt;<br />
      <span class="indent">
        in foo<br />
      </span>
      &lt;!--#elif expr='"$DOCUMENT_URI" = "/bar/file.html"' --&gt;<br />
      <span class="indent">
        in bar<br />
      </span>
      &lt;!--#else --&gt;<br />
      <span class="indent">
        in neither<br />
      </span>
      &lt;!--#endif --&gt;
    </code></p></div>
</div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<div class="section">
<h2><a name="flowctrl" id="flowctrl">Flow Control Elements</a></h2>
    

    <p>The basic flow control elements are:</p>

    <div class="example"><p><code>
      &lt;!--#if expr="<var>test_condition</var>" --&gt;<br />
      &lt;!--#elif expr="<var>test_condition</var>" --&gt;<br />
      &lt;!--#else --&gt;<br />
      &lt;!--#endif --&gt;
    </code></p></div>

    <p><code>if</code> element works like an if statement in a
    programming language. The test condition is evaluated and if
    the result is true, then the text until the next <code>elif</code>, <code>else</code>或<code>endif</code> element is included in the
    output stream.</p>

    <p><code>elif</code>或<code>else</code> statements are be used
    to put text into the output stream if the original
    <var>test_condition</var> was false. These elements are optional.</p>

    <p><code>endif</code> element ends the <code>if</code> element
    and is required.</p>

    <p><var>test_condition</var> is one of the following:</p>

    <dl>
      <dt><code><var>string</var></code></dt>
      <dd>true if <var>string</var> is not empty</dd>

      <dt><code><var>string1</var> = <var>string2</var><br />
      <var>string1</var> == <var>string2</var><br />
      <var>string1</var> != <var>string2</var></code></dt>
      
      <dd><p>Compare <var>string1</var> with <var>string2</var>. If
      <var>string2</var> has the form <code>/<var>string2</var>/</code>
      then it is treated as a regular expression. Regular expressions are
      implemented by the <a href="http://www.pcre.org">PCRE</a> engine and
      have the same syntax as those in <a href="http://www.perl.com">perl
      5</a>. Note that <code>==</code> is just an alias for <code>=</code>
      and behaves exactly the same way.</p>

      <p>If you are matching positive (<code>=</code>或<code>==</code>), you
      can capture grouped parts of the regular expression. The captured parts
      are stored in the special variables <code>$1</code> ..
      <code>$9</code>.</p>

      <div class="example"><h3>示例</h3><p><code>
        &lt;!--#if expr="$QUERY_STRING = /^sid=([a-zA-Z0-9]+)/" --&gt;<br />
        <span class="indent">
          &lt;!--#set var="session" value="$1" --&gt;<br />
        </span>
        &lt;!--#endif --&gt;
      </code></p></div>
      </dd>

      <dt><code><var>string1</var> &lt; <var>string2</var><br />
       <var>string1</var> &lt;= <var>string2</var><br />
       <var>string1</var> &gt; <var>string2</var><br />
       <var>string1</var> &gt;= <var>string2</var></code></dt>

      <dd>Compare <var>string1</var> with <var>string2</var>. Note, that
      strings are compared <em>literally</em> (using
      <code>strcmp(3)</code>). Therefore the string "100" is less than

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -