Skip to the content
Documentation
Help Start
Reading in:
  • German: 9,059 of 9,059 pages
About the help in other languages
All help pages

PHP string functions as operators

The sixty-odd PHP string functions available as template operators since 6.0.13 (strlen, substr, str_contains, sprintf, number_format, strip_tags, ...), how the piped value maps to PHP's first argument, and…

Download as PDF

Address: https://doc.exponential.earth/exphelp/viewer/help/designers/templates/string-template-operators.md

On this page

PHP string functions as operators

This page is for designers who need a text function the classic operators do not have. Since release 6.0.13, the class eZTemplateStringsOperator (lib/eztemplate/classes/eztemplatestringsoperator.php) makes about sixty PHP string functions available in templates. The full list and the details are on the feature page PHP string functions as template operators.

Contents

  1. How the mapping works
  2. Useful for designers
  3. Notes

How the mapping works

The piped value is PHP's first argument; the template parameters follow in PHP's order:

{def $text = 'Hello, Exponential'}
{$text|strlen}                    {* 18 *}
{$text|substr( 0, 5 )}            {* Hello *}
{$text|str_contains( 'Expo' )}    {* true *}
{$text|lcfirst}                   {* hello, Exponential *}

(examples from the feature page).

Useful for designers

NeedOperator
plain text from rich textstrip_tags (then shorten and wash)
first characterssubstr( 0, 1 ) for an initial
does a text start or end withstr_starts_with, str_ends_with
number with separatorsnumber_format( 2, ',', '.' ) (or l10n( 'number' ) for the locale's format)
formatted textsprintf( '%02d', $n )
position of a substringstrpos, stripos
split into charactersstr_split

Notes

  • Prefer the locale-aware l10n for numbers and dates shown to visitors (Dates, numbers and l10n).
  • These operators return raw text: wash before printing.
  • A few functions exist only on newer PHP versions; the feature page says which.

Become an Exponential Partner

Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.

Something wrong on this page? Report an error

Documentation license

This documentation is free documentation, licensed under the GNU Free Documentation License 1.3 or later.

Exponential Copyright © 1998-2026 Exponential Foundation and 7x