---
title: "Constant ViewHelper <f:constant>"
manual: "Fluid ViewHelper Reference"
version: "13.4"
permalink: "https://docs.typo3.org/permalink/t3viewhelper:typo3fluid-fluid-constant@13.4"
source: "Global/Constant.rst"
modified: "2026-09-17T09:07:45+00:00"
---

# Constant ViewHelper `<f:constant>`

> [!NOTE]
> The constant ViewHelper can display **PHP constants** only. It cannot be
> used to display [TypoScript Constants](https://docs.typo3.org/m/typo3/reference-typoscript/13.4/en-us/UsingSetting/Constants.html#typoscript-syntax-constants)
> or [Site settings](https://docs.typo3.org/m/typo3/reference-coreapi/13.4/en-us/ApiOverview/SiteHandling/SiteSettings.html#sitehandling-settings).

Wrapper for PHPs `constant` function.
See [https://www.php.net/manual/function.constant.php](https://www.php.net/manual/function.constant.php).

Go to the source code of this ViewHelper: [ConstantViewHelper.php (GitHub)](https://github.com/TYPO3/Fluid/blob/main/src/ViewHelpers/ConstantViewHelper.php).

**Table of contents**

-   [Displaying global PHP constants in Fluid](https://docs.typo3.org/permalink/t3viewhelper:displaying-global-php-constants-in-fluid@13.4)
-   [Get class constant](https://docs.typo3.org/permalink/t3viewhelper:get-class-constant@13.4)
-   [Using enum cases in Fluid](https://docs.typo3.org/permalink/t3viewhelper:using-enum-cases-in-fluid@13.4)
-   [Arguments of the <f:constant> ViewHelper](https://docs.typo3.org/permalink/t3viewhelper:arguments-of-the-f-constant-viewhelper@13.4)

## Displaying global PHP constants in Fluid

You can display [global PHP constants](https://www.php.net/manual/en/reserved.constants.php)
using this ViewHelper

**packages/my_extension/Resources/Private/Templates/Info/SystemInfo.fluid.html**

```html
Maximal possible number: {f:constant(name: 'PHP_INT_MAX')}

<f:if condition="{f:constant(name: 'PHP_MAJOR_VERSION')} >= 8">
    Using PHP 8.0 or greater
</f:if>
```

## Get class constant

You can display any **public** class constant from a class within TYPO3,
for example constants from `\TYPO3\CMS\Core\Information\Typo3Information`:

```html
Join the <f:link.external uri="{f:constant(name: '\TYPO3\CMS\Core\Information\Typo3Information::URL_COMMUNITY')}">
    TYPO3 Community
</f:link.external>!
```

## Using enum cases in Fluid

Cases of enums are objects and not strings or integers. They cannot be directly
output in the template. You can however save them into a variable and
then use their value. For example you can use values of the enum cases in
`\TYPO3\CMS\Core\Resource\FileType` to compare them with a value of your
object:

**packages/my_extension/Resources/Private/Templates/Info/SystemInfo.fluid.html**

```html
<f:variable name="imageType"><f:constant name="\TYPO3\CMS\Core\Resource\FileType::IMAGE"/></f:variable>
The image case has the value {imageType.value} and name {imageType.name}:
<f:if condition="{myFile.type} === {imageType.value}">
    This file is an image!
</f:if>
```

## Arguments of the `<f:constant>` ViewHelper

-   **name**

    -   *Type:* string

    String representation of a PHP constant or enum
