PEAR Manual
Prev |  | Next

# {variable}

{variable} -- creates PHP code to echo a variable

## Synopsis

``Usage` ({variable}, {variable:h}, {variable:u})`

## Description

creates PHP code to echo a variable, with optional modifier. Modifiers are

- No Modifier - does htmlspecialchars($variable)

- :h - echos without any change - eg. raw

- :u - echos urlencode($variable)

by default variables are assumed to have calling scope, and are prefixed with $t->, however if they are inside a loop (foreach), then the variables created by the loop are added to the scope and the prefix is not added.

## Example

Example 41-1. setting an object variable
    $this->a = "hello >>";
    $template->outputObject($this);

Example 41-2. Outputting the variable
    {a}
    {a:h}
    {a:u}

Example 41-3. Compiled template
    <?php echo htmlspecialchars($t->a); ?>
    <?php echo  $t->a; ?>
    <?php echo urlencode($t->a); ?>

Example 41-4. Simple ouput example
    hello &gt;&gt;
    hello >>
    hello+%3E%3

Prev | Home | Next
$factory->setRequired() | Up | {method(arguments,#quoted arguments#)}