eq
Summary
Returns TRUE if the input equals the first parameter or if all parameters are equal.Usage
input|eq( value1 [, value2 ] )
Parameters
Name | Type | Description | Required |
---|---|---|---|
value1 | any | A variable/value that should be compared. | Yes. |
value2 | any | Another variable/value that should be copmared. | No. |
Returns
TRUE or FALSE (see below).Description
This operator compares the contents of two or more variables and/or values. If the input parameter is used, the operator will compare it with the first parameter. If the provided variables/values match, the operator will return TRUE, otherwise FALSE will be returned. If more than one parameter is provided, the operator will compare all parameters. If all parameters are found to be equal, the operator will return TRUE, otherwise FALSE will be returned. If more than one parameter is provided, the operator will simply ignore the input parameter.
Note that "eq" compares the values in the same way as the '==' operator in PHP programming language (for example, 0.1 and 0.10 will be equal). Refer to the PHP reference documentation for more information. It is recommended to use the “compare” template operator for string comparision.
Examples
Example 1
{if 1|eq( 1 )} The truth is out there. {else} The day the earth stood still. {/if}
The following output will be produced: "The truth is out there".
Example 2
{if 1|eq( 2 )} The truth is out there. {else} The day the earth stood still. {/if}
The following output will be produced: "The day the earth stood still".
Example 3
{if eq( 1, 1 )} The truth is out there. {else} The day the earth stood still. {/if}
The following output will be produced: "The truth is out there".
Example 4
{if eq( 1, 2 )} The truth is out there. {else} The day the earth stood still. {/if}
The following output will be produced: "The day the earth stood still".
Example 5
{if 1|eq( 1, 1 )} The truth is out there. {else} The day the earth stood still. {/if}
The following output will be produced: "The truth is out there".
Example 6
{if 2|eq( 1, 1 )} The truth is out there. {else} The day the earth stood still. {/if}
The following output will be produced: "The truth is out there.".
Example 7
{if 1|eq( 1, 2 )} The truth is out there. {else} The day the earth stood still. {/if}
The following output will be produced: "The day the earth stood still".
Balazs Halasy (05/02/2004 10:39 am)
Geir Arne Waaler (31/05/2010 1:23 pm)
Comments
usage tip
Friday 03 February 2006 7:23:50 pm
Samuel Sauder
input|eq( value1 [, value2 [,...] ] )
or
eq( value1 [, value2 [,...] ] )
Re: usage tip
Sunday 19 February 2006 4:04:47 pm
Marc Boon
it makes no sense to specify more than one value, they are ignored.
evaluates to ..
Friday 18 August 2006 4:51:16 pm
Pike
is an empty string equal to 0 or null or none ?
is undefined defined ?
what would be wise to use as a default for 'no value' ?
Re: evaluates to ..
Wednesday 04 July 2007 4:56:47 pm
Arnaud Lafon
{''|eq(0)}
returns
1 (i.e. true...)
Re: evaluates to ..
Tuesday 27 May 2008 4:36:07 pm
Adrien
Re: evaluates to ..
Wednesday 28 May 2008 8:32:44 am
Adrien