On line guide/help

You are on page 39 of the online help. Navigate sequentially through the guide pages or search for a topic of interest to you.

Index Prev. Next

Data

Variables

Set variables in the PHP code and in the template

A variable is a value identified by a name, printed in the template with the placeholder {VARIABLE_NAME}. Variables can be set in the PHP code, with the SetVar and SetVars methods, or in the template, with the <var> element. The variable names are case insensitive (they are stored in uppercase).

Some variables are used by the library for the value formatting (eg. CURRENCYSYMBOL): see the Value formatting page.

Variables in the PHP code

SetVar($name, $value, $overwrite = true) Sets a variable. With $overwrite = false an existing variable is not changed.
SetVars($list, $overwrite = true) Sets more variables with an associative array (name => value).
GetVar($name, $default = '') Returns the value of a variable, or the default value if the variable does not exist.

Set variables in the PHP code

The var element

Elements / attributes of the <var> element (aliases: <setvar>, <set_var>), that can be used in a section or in a content:

<name> (required) Variable name
<value> (required, it cannot be empty) Variable value. Placeholders are not replaced in the value.
<overwrite> What to do if the variable already exists: yes (default, also 1, y, t, true) replace its value, no keep the existing value

The template is processed after the PHP code has set its variables: with overwrite="no" the template can define default values, that the PHP code can change with SetVar before calling BuildReport.

Variables set in the template