array
HTML_Template_IT::getGlobalvariables (
)
全グローバル変数の配列を変数キャッシュから取得します。 HTML_Template_IT::setVariable() を使用して代入した変数のみが返されます。返される値は二つで、 最初の値はグローバル変数の名前の配列です。 二番目の値がすべての変数の配列となります。
array
- 配列を返します。
キー 0 には代入された変数の名前が配列で格納され、キー 1
には対応する値が配列で格納されます。
スクリプト
<?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);
// 変数 {page} を設定します。これが getGlobalvariables で返されます。
$tpl->setVariable("page", "http://example.com");
$tpl->setVariable("username", "foo");
// getGlobalvariables は {username} を返しません。グローバル変数ではないからです。
// また {visitorcount} も返しません。設定されていないからです。
print_r($tpl->getGlobalvariables());
?>
出力
This function can not be called statically.