is_numeric
Summary
Returns TRUE if the provided variable is a number.Usage
input|is_numeric( target )
Parameters
Name | Type | Description | Required |
---|---|---|---|
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 a number or a numeric string (a string containing a number). 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.
Examples
Example 1
{def $my_variable=3} {if $my_variable|is_numeric()} It is a number. {else} It is not a number. {/if}
The following output will be produced: "It is a number.".
Example 2
{def $my_variable='256'} {if is_numeric( $my_variable )} It is a number. {else} It is not a number. {/if}
The following output will be produced: "It is a number.".
Example 3
{def $a=3 $b='Mobile instrument.'} {if $a|is_numeric( $b )} It is a number. {else} It is not a number. {/if}
The following output will be produced: "It is not a number.".
Balazs Halasy (05/02/2004 12:35 pm)
Balazs Halasy (06/05/2005 7:26 am)
Comments
There are no comments.