Skip to the content
Documentation

or

No ratings yet

Summary

Evaluates all parameters until one is found to be TRUE, returns that value.

Usage

or( value1 [, value2 [, ... ] ] )

Parameters

Name Type Description Required
value1 any A variable/value to be evaluated. Yes.
value2 any Another variable/value to be evaluated. No.

Returns

One of the parameters or FALSE (see below).

Description

This operator evaluates all parameters until one of them is found to be TRUE. The operator will then return that parameter and thus stop evaluating the rest of the parameters. If none of the parameters are found to be TRUE, the operator will return FALSE. The following table shows how the different types are evaluated by this operator.

Type Evaluation
Number TRUE if the value is non-zero, FALSE otherwise.
String TRUE if the string consists of at least one character, FALSE otherwise.
Boolean TRUE if the boolean is a TRUE value, FALSE is otherwise.
Array TRUE if the array has one or more elements, FALSE otherwise.
Object TRUE if the object provides the "attributes" and the "attribute" methods, FALSE otherwise.
NULL Always FALSE.
Other Other types will be evaluated in the same way as PHP would do.

Examples

Example 1

{if or( false(), true(), false() )}
    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

{def $a=array()
     $b=array( 1, 2, 3 )
     $c=array( 4, 5, 6 )}

{or( $a, $b, $c )}

The code above will return the following array: ( 1, 2, 3 ).

Contributors

Comments

Add a comment

Comments are read by a moderator before they appear.