Caution: This documentation is for eZ Publish legacy, from version 3.x to 5.x.
For 5.x documentation covering Platform see eZ Documentation Center, for difference between legacy and Platform see 5.x Architecture overview.

get_type

Summary

Returns the type of the provided variable.

Usage

input|get_type( target )

Parameters

NameTypeDescriptionRequired
target any The target variable. Only if the input parameter is omitted.

Returns

A string containing the type of the provided variable.

Description

This operator can be used to check the type of a variable. It returns the type of the input parameter or the target variable as a string. If both the input parameter and the target variable are provided, it is the target variable 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 number of elements will be returned.
  • If the data is a string, the string "string" and the length of the string will be returned.

Examples

Example 1

{def $my_variable='ich bin'}
{$my_variable|get_type()}

The following output will be produced: "string".

Example 2

{def $my_variable='ich bin'
     $your_variable=array( 'du', 'bist' )}
 
{$my_variable|get_type( $your_variable )}

The following output will be produced: "array[2]".

Balazs Halasy (05/02/2004 12:30 pm)

Balazs Halasy (06/05/2005 7:19 am)


Comments

There are no comments.