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