DEPRECATION WARNING
This documentation is not using the current rendering mechanism and is probably outdated. The extension maintainer should switch to the new system. Details on how to use the rendering mechanism can be found here.
API¶
This section describes the API made available in the parser class
(\Cobweb\Expressions\ExpressionParser
).
All the methods are static, so there's no need to create an instance of the parser class. To evaluate a string, simply make a call like:
$parsedString = \Cobweb\Expressions\ExpressionParser::evaluateString($string, TRUE);
evaluateExpression¶
This method evaluates a single expression and returns the value.
- Parameters
- $expression
- The string to parse and evaluate. This string is not
expected to contain subexpressions. Use
evaluateString()
instead.
evaluateString¶
This method parses a string and evaluates every expression that it contains. Furthermore the resulting string itself can be evaluated as an expression.
- Parameters
- $string
- The string to parse. It may contain subexpressions, which will be parsed appropriately.
- $doEvaluation
- Boolean, true by default. If true the string itself is evaluated as an expression, after all subexpressions have been evaluated. If false, the string itself is not evaluated.
setVars¶
This method can be used to store so-called "internal" variables inside a static member variable of the parser class (see below).
- Parameters
- $vars
- An array of any size.
- $reset
- Boolean. If true, the existing "internal" variables will be
overridden by the content of
$data
. If false (which is the default), the content of $data is merged with existing "internal" variables.
setExtraData¶
This method can be used to store so-called "external" variables inside a static member variable of the parser class (see below).
- Parameters
- $data
- An array of any size.
- $reset
- Boolean. If true, the existing "external" variables will be
overridden by the content of
$data
. If false (which is the default), the content of $data is merged with existing "external" variables.