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

is_integer

Summary

Returns TRUE if the provided variable is an integer.

Usage

input|is_integer( target )

Parameters

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

Returns

TRUE or FALSE.

Description

This operator checks if the input parameter or the target variable is an integer. If it is, the operator will return TRUE, otherwise FALSE will be returned. If both the input parameter and the target variable are provided, it is the target variable that will be evaluated.

Note: "is_integer" works like "is_int" in php, in other words a string with number in it will return false.

Examples

Example 1

{def $my_variable=3}
 
{if $my_variable|is_integer()}
    It is an integer.
{else}
    It is not an integer.
{/if}

The following output will be produced: "It is an integer.".

Example 2

{def $my_variable=3}
 
{if is_integer( $my_variable )}
    It is an integer.
{else}
    It is not an integer.
{/if}

The following output will be produced: "It is an integer.".

Example 3

{def $a=3
     $b='Mobile instrument.'}
 
{if $a|is_integer( $b )}
    It is an integer.
{else}
    It is not an integer.
{/if}

The following output will be produced: "It is not an integer.".

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

Geir Arne Waaler (07/10/2011 7:21 am)

Balazs Halasy, Ester Heylen, Geir Arne Waaler


Comments

There are no comments.