Prev |  | Next

#### 1.4.3.3. PHP constants

It is possible to define constants within PHP. This is done using the define() PHP statement. Here's an example:

    <?php define("MY_CONSTANT", "The constant value") ?>

You can reference PHP constants from the template language by using its name, without any quotes. So the constant that was defined in the code above, can be used like this in a template:

Example 1.8. Code using a PHP constant definition

    The value of my PHP constant is {MY_CONSTANT}

Apart from defining your own PHP constants, you can also use constants that are already defined by PHP. Two useful constants to use are `true` (value = 1) and `false` (value = 0). Using these, you can write template code like this:

Example 1.9. Code using built-in PHP constants

    {VAR SOME_OPTION true}

    {IF SOME_OPTION true}
      The option SOME_OPTION is true.
    {/IF}

Prev | Up | Next
| Home |