HTML_Template_IT::getGlobalvariables()

HTML_Template_IT::getGlobalvariables() – returns an array of all global variables from the variable cache

Synopsis

require_once 'HTML/Template/IT.php';

array HTML_Template_IT::getGlobalvariables ( )

Description

Gets an array of all global variables in the variable cache. Only variables that are filled using HTML_Template_IT::setVariable() are returned. The returned has two values. The first values holds an array with the names of the global variables, the second value holds an array with all the values.

Return value

array - An array. The key 0 holds an array with the names of all filled variables, the key 1 holds an array with names of the according values.

Example

Script

<?php

require_once("HTML/Template/IT.php");

$template = <<<EOF
<!-- BEGIN a -->
    Hello {username}
<!-- END a -->
Welcome to {page},
You are visitor number {visitorcount}.
EOF;

$tpl = new HTML_Template_IT('.');
$tpl->setTemplate($template);

// set the {page} variable. It will be returned by getGlobalvariables then.
$tpl->setVariable("page""http://example.com");
$tpl->setVariable("username""foo");

// getGlobalvariables won't return {username} as it is not a global variable
// It won't return {visitorcount} as it is not set
print_r($tpl->getGlobalvariables());

?>

The output

   
Array
(
    [0] => Array
        (
            [0] => @{page}@
        )

    [1] => Array
        (
            [0] => http://example.com
        )

)

Note

This function can not be called statically.