Template: ezcTemplateVariableCollection
[ ]
[ EBNF ] [ Functions ] [ Syntax ]
[ ]
[ ]
[ ]
[ ]
Class: ezcTemplateVariableCollection
|
Contains the template variables. [
source]
Implemented Interfaces
- Iterator (internal interface)
The next example sets and gets variables:
1. $collection = new ezcTemplateVariableCollection();
2. $collection->character = "Londo Mollari";
3. $collection->actor = "Peter Jurasik";
4. $collection->race = "Centauri";
5.
6. echo "Race: " . $collection->race;
The next example shows all variables using the iterator.
1. <?php
2. $send = new ezcTemplateVariableCollection();
3.
4. $send->red = "FF0000";
5. $send->green = "00FF00";
6. $send->blue = "0000FF";
7.
8. foreach ( $send as $name => $value )
9. {
10. echo ( "$name -> $value\n" );
11. }
12. ?>
Method Summary
|
public ezcTemplateVariableCollection |
__construct(
[$variables = array()] )
Initialises an empty collection of variables. |
|
public void |
current(
)
Returns the current variable |
|
public array(ezcTemplateVariable) |
getVariableArray(
)
Returns all variables in an array. |
|
public void |
key(
)
Returns the current key. |
|
public void |
next(
)
Proceed to the next element. |
|
public void |
removeVariable(
$name )
Removes the variable named $name from the collection. |
|
public void |
rewind(
)
Iterator rewind method |
|
public void |
valid(
)
Returns true if the iterator is at a valid location. |
|
public mixed |
__get(
$name )
Returns the value of the variable $name. |
|
public bool |
__isset(
$name )
Returns true if the variable $name is set. |
|
public void |
__set(
$name, $value )
Sets the value $value to the variable $name. |
Methods
__construct
ezcTemplateVariableCollection __construct(
[array
$variables = array()] )
Initialises an empty collection of variables.
Parameters
| Name |
Type |
Description |
$variables |
array |
An array of variables to initialise the collection with. The default is an empty collection. |
current
void current(
)
Returns the current variable
getVariableArray
array(ezcTemplateVariable) getVariableArray(
)
Returns all variables in an array.
key
void key(
)
Returns the current key.
next
void next(
)
Proceed to the next element.
removeVariable
void removeVariable(
string
$name )
Removes the variable named $name from the collection.
If the variable doesn't exist, it returns false.
Parameters
| Name |
Type |
Description |
$name |
string |
The name of the variable to remove. |
rewind
void rewind(
)
Iterator rewind method
valid
void valid(
)
Returns true if the iterator is at a valid location.
__get
mixed __get(
$name )
Returns the value of the variable $name.
Parameters
| Name |
Type |
Description |
$name |
|
|
__isset
bool __isset(
$name )
Returns true if the variable $name is set.
Parameters
| Name |
Type |
Description |
$name |
|
|
__set
void __set(
$name,
$value )
Sets the value $value to the variable $name.
Parameters
| Name |
Type |
Description |
$name |
|
|
$value |
|
|
Last updated: Wed, 28 Nov 2007