Tutorial 8 : Advanced options of the method setVars() - neeftarah/odtphp GitHub Wiki

The purpose of this tutorial is to show optional parameters of the method setVars().

The PHP code

<?php
$odf->setVars($key, $value, $encode, $charset);
?>

The method setVars() requires just two parameters : the name $key of a tag within the template and a text $value. However, two optional arguments can be provided.

$encode is a boolean. If this parameter is equal to true, special HTML characters (<, >, ", &) will be encoded in entities. By default, this parameter equals to true. If you set it to false, you will be able to insert raw XML data.

$charset is name of a characters set. By default, this parameter equals to 'ISO-8859'. Data are so automatically encoded in UTF-8 before adding them in the XML document. If you set this parameter to 'UTF-8', then data will not be encoded a second time in UTF-8. This can be useful to provide to the template data that are already encoded in UTF-8.