varinfo - get miscellaneous variable information

 

SYNOPSIS

<varinfo $action [flags ...] [$arg]>


DESCRIPTION
The varinfo function returns various information about variables, depending on the value of the $action argument:

  • list Returns the names of all known variables in the current scope. This includes unlisted environment/CGI variables only accessible via getvar. If the optional $arg argument is given, then only variables from a specific source will be returned:

    • URL for URL (query string) variables

    • ENV for environment variables

    • CONTENT for POST method form variables

    • CGI for POST and/or query-string variables

    • COOKIE for cookie variables
    Each of the returned variable names can be passed to getvar to obtain its value(s).

  • size Returns the size in bytes of each corresponding value of the variable named by $arg. This is useful to obtain the true size of a varbyte variable such as an image, where strlen might stop short.

  • type Returns the SQL type of the variable named by $arg, as a string. The type action was added in version 2.6.929000000 19990610.

  • dump   Returns debug information about the variable named by $arg, as a string. This information is in the same format as printed by the $?myVar debug syntax (here). Accessing debug info via <varinfo dump> can be used when the variable name must be determined dynamically at run-time, precluding usage of the easier (but static-name) $?myVar syntax. Added in version 6.

  • dumpverbose

    Like dump, but more verbose: uses the $??myVar syntax. Added in version 6. In version 7.03 and later, this is deprecated: use <varinfo dump verbose ...> instead.

The following actions are applicable only to <INPUT TYPE=file> variables from a multipart MIME file upload (here). For any other variables, nothing is returned:

  • filename Returns the filename for the variable named by $arg, from the Content-Disposition header. This corresponds to the name of the file the user gave for that field, from their system. Note that the full path is generally not available; only the filename is usually sent by the browser.

  • contenttype Returns the Content-Type for the variable given by $arg.

In version 7.03 and later, the following flags may be set before the final $arg argument. Currently they are only valid for the dump and dumpverbose actions:

  • esc

    Force HTML-escapement of variable values printed by dump, regardless of HTML mode.

  • noesc

    Force as-is (no HTML escapement) printing of variable values printed by dump. By default, HTML escapement happens if the script is in HTML mode; using this flag may be useful to avoid escapement when an HTML-mode Web script is being debugged to a log file that is being read as plain text.

  • verbose

    Dump variables in verbose mode (ala $??myVar).


DIAGNOSTICS
The varinfo function returns various information about variables, per its arguments.


EXAMPLE

<A NAME=main>
  <FORM METHOD=post ACTION="$url/test.html"
        ENCTYPE="multipart/form-data">
    Image: <INPUT TYPE=file NAME=image>
    <INPUT TYPE=submit NAME=submit>
  </FORM>
</A>

<A NAME=test>
  <varinfo list CGI>
  Form variables are: <LOOP $ret> $ret </LOOP> <BR>
  <varinfo filename "image">
  You uploaded the file "$ret".
  <varinfo contenttype "image">
  It is of type "$ret" and
  <varinfo size "image"> $ret bytes in size.
</A>


CAVEATS
The varinfo function was added in version 2.6.926900000 19990517.

The size of variables is the size of the native type, not the string representation as strlen would return. E.g. integer vars on a 32-bit machine will always have a size of 4.

While the list cgi action will return CGI variable names, their values, obtained with the getvar function, may be different if the variable(s) have been modified. Similarly, the filename and contenttype of variables may not correspond to their current values, if they were modified.


SEE ALSO
getvar


Copyright © Thunderstone Software     Last updated: Sep 25 2019
Copyright © 2019 Thunderstone Software LLC. All rights reserved.