Horde_Template::set PHP Method

set() public method

Sets a tag, loop, or if variable.
public set ( string | array $tag, mixed $var )
$tag string | array Either the tag name or a hash with tag names as keys and tag values as values.
$var mixed The value to replace the tag with.
    public function set($tag, $var)
    {
        if (is_array($tag)) {
            foreach ($tag as $tTag => $tVar) {
                $this->set($tTag, $tVar);
            }
        } elseif (is_array($var)) {
            $this->_arrays[$tag] = $var;
        } else {
            $this->_scalars[$tag] = (string) $var;
        }
    }

Usage Example

Example #1
0
 public function testScalar()
 {
     $template = new Horde_Template();
     $template->set('one', 'one');
     $template->set('two', 2);
     $this->assertEquals("one\n2", $template->parse("<tag:one />\n<tag:two />"));
 }
All Usage Examples Of Horde_Template::set