#native_company# #native_desc#

Cached Dynamic Modules pt 3 Page 3

By Travis Swicegood
on July 30, 2000


In several areas there were repetitive if() statements, and several if()
statements that were better used as elseif(). Also, several of the while()
statements were changed to for() statements, as well as several for()
statements had some repetitive function calls that weren’t necessary. All
in all, the changes were minor, but in a shared server environment, could
cause extreme havoc on the system performance.

The parse() and parse_it() functions were changed to the following:

function parse( $doc_root, $file, $_debug = false)
function parse_it( $str, $doc_root, $use_tag, $_debug = false, $def_cache_time = 3600 )
  • $doc_root is the equivalent of PHP’s $DOCUMENT_ROOT. There were
    some problems accessing the global variable, so it was added into the function calls.
  • $_debug has been added to enable/disable debugging mode.
    By default, debugging mode is turned off.
  • $use_tag in the parse_it() function is the dynamically
    generated custom tag (example $use_tag = “my” if the file extension is “.my”)
  • $def_cache_time in the parse_it() is used to change
    the default cache time. If it is not set, 3600 seconds (60 minutes) is assumed.
  • $str & $str were respectively carried over from
    their original purpose with their own functions

The comments within the file parse.php3 have been extensively
revised. So much so, that documentation outside the file would be extremely
redundant. Also added in the comments section at the bottom of the file
are instructions on how to setup parse.php3 to run, as well as
example files to test the parser out.

To avoid any potential problems with the parse() and
parse_it() functions not being default, the initial call
to parse() has been moved to the end of the file, but
before the setup instructions.