* @param $var The variable we are looking for
* @param $value The value we want to store in the variable
* @return void
+ * @throws EmptyVariableException If the variable name is left empty
*/
public final function assignVariable ($var, $value) {
+ // Trim spaces of variable name
+ $var = trim($var);
+
+ // Empty variable found?
+ if (empty($var)) {
+ // Throw an exception
+ throw new EmptyVariableException(array($this, 'var'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
+ } // END - if
+
// First search for the variable if it was already added
$idx = $this->isVariableAlreadySet($var);
// Was it found?
if ($idx === false) {
// Add it to the stack
+ //* DEBUG: */ echo "ADD: ".$var."<br />\n";
$this->addVariable($var, $value);
} elseif (!empty($value)) {
// Modify the stack entry
+ //* DEBUG: */ echo "MOD: ".$var."<br />\n";
$this->modifyVariable($var, $value);
}
}
if ((is_array($variableMatches)) && (count($variableMatches) == 4) && (count($variableMatches[0]) > 0)) {
// Initialize all missing variables
foreach ($variableMatches[3] as $key=>$var) {
- // Try to assign it, empty strings are being ignored
- $this->assignTemplateVariable($variableMatches[1][$key], $var);
+ // Variable name
+ $varName = $variableMatches[1][$key];
+
+ // Workarround: Do not assign empty variables
+ if (!empty($var)) {
+ // Try to assign it, empty strings are being ignored
+ $this->assignTemplateVariable($varName, $var);
+ } // END - if
} // END - foreach
} // END - if
}
);
// Did something change?
- if (strlen($eval) != $eval) {
+ if (strlen($eval) != $evalLength) {
// Run the constructed command. This will "compile" all variables in
@eval($eval);
} // END - if