ez.no / exponential / documentation / reference / template operators / variables / get_type
$input|get_type( test )
| Name | Type | Description | Required |
|---|---|---|---|
| test | any | Variable to check. | Only if input is omitted. |
string containing info about variable
This operator can be used to check the type of a variable. The operator returns the type of the input or the first parameter. The operator returns a string.
If both input and parameter are supplied, it is the parameter that will be evaluated.
If the data is an object, the string 'object' and the name of the class will be returned.
If the data is an array, the string 'array' and the array count will be returned.
If the data is a string, the string 'string' and the lenght of the string will be returned.
Example 1
{let my_variable="ich bin" your_variable=array( "du", "bist" ) } {$my_variable|get_type( $your_variable )} {/let}
returns the string: "array[2]".
Example 2
{let my_variable="ich bin" your_variable=array( "du", "bist" ) } {$your_variable|get_type( $my_variable )} {/let}
returns the string: "string[7]".
log in or create a user account to comment.
Comments