PAD - PHP Application Driver


home | manual | reference | regression | sequence | develop | apps


Pipes

Pipes - Transform Output with Functions

Pipes allow you to pass output through functions to transform it. Use the pipe symbol | followed by a function name to process data.

Two Ways to Use Pipes

1. Variable Pipes

Apply functions to variables using {echo $variable | function}:

PHP
HTML
Result

2. Tag Pipes

Apply functions to tag output. Pipes can be placed on the opening tag or closing tag:

PHP
HTML
Result

Pipe Timing: Opening vs Closing Tag

The placement of the pipe determines when the function is applied:

  • Opening tag {tag | function} - Processes data BEFORE the tag content is rendered
  • Closing tag {/tag | function} - Processes output AFTER the tag is finished
PHP
HTML
Result

Chaining Pipes

Chain multiple pipe functions together by separating them with |. Functions are applied left to right:

PHP
HTML
Result

Common Pipe Functions

Function Description Example
upper Convert to uppercase {echo $text | upper}
lower Convert to lowercase {echo $text | lower}
ucwords Capitalize each word {echo $text | ucwords}
trim Remove whitespace {echo $text | trim}
html HTML encode {echo $text | html}
replace(a,b) Replace text {echo $text | replace('old','new')}
+ n Add number {echo $count | + 1}
date(fmt) Format date {echo $timestamp | date('Y-m-d')}

Important Rules

  • Use {echo} with variables - {echo $var | function} NOT {$var | function}
  • Arithmetic needs spaces - {echo $x | + 1} NOT {echo $x | +1}
  • Quote string parameters - {echo $x | replace('a','b')}
  • Functions apply left to right - {echo $x | trim | upper} trims first, then uppercases

When to Use Opening vs Closing Tag Pipes

Use Case Placement Example
Transform input data before processing Opening tag {items | sort}...{/items}
Transform final output after rendering Closing tag {tag}...{/tag | upper}
Format variable values Variable pipe {echo $price | number_format(2)}

See Also

  • {echo} - Evaluate and output expressions
  • {functions} - List of all pipe functions
  • {options} - Tag options reference

Basic Concepts

  

Advanced concepts

  

Constructs

Miscellaneous




home | manual | reference | regression | sequence | develop | apps

(c) 2003-2025 Herbert Groot Jebbink