Bitrix Site Manager

Notes on $arParams and $arResult

$arParams

$arParams is the predefined variable containing an array of the component input parameters. Keys are the names of parameters, and the values are parameter values.

Before the component is activated, htmlspecialcharsEx is called on values of all parameters.

The original parameter values are stored in this array but have the prefix of tilde "~". For example, $arParams["NAME"] is an input parameter processed with htmlspecialcharsEx, and $arParams["~NAME"] is the original parameter.

The variable $arParams is a reference to the corresponding component class member, so all changes to this variable affect the class member. On startup, the component should verify input parameters, initialize variables, cast types (e.g. IntVal). The template will have access to these altered parameters; that is, parameters will be verified and safe. The template does not have to verify and prepare parameters again.

$arResult

$arResult is the predefined variable accumulating the component's output before trensferring it to the template. Before the component is activated, this variable is set to an empty array().

$arResult is a reference to the corresponding component class member, so all changes to this variable affect the class member. Do not pass this variable to the template explicitly; it is performed by the component internal logic.

PHP references

PHP references are used to address a piece of information by different names. All changes to $arParams and $arResult will be available in the template as well.

References are powerful, but you may come across some pitfalls.