assign_by_ref

void assign_by_ref(string varname, mixed var)

This is used to assign values to the templates by reference instead of making a copy. See the PHP manual on variable referencing for an explanation.

Technical Note: assign_by_ref() is more efficient than assign() since it does not create an in-memory copy of the variable. Instead it refers to the actual variable in the memory heap. Be aware if you alter the original variable after it is assigned, the assigned variable sees the changes! PHP 5.0 will take care of referencing automatically, so this function acts as a workaround.

Example 13-4. assign_by_ref

// passing name/value pairs
$smarty->assign_by_ref("Name",$myname);
$smarty->assign_by_ref("Address",$address);