Article • Technology

PHP 8.5: The Pipe Operator (|>)

Admin Jan 01, 2026 Technology

PHP 8.5: The Pipe Operator (|>) — writing logic the way we think

One of the most readable ideas coming into modern PHP is the pipe operator.

Instead of nesting function calls or storing temporary variables, you pass the result forward step-by-step.

Before (traditional):

$result = formatPrice( applyDiscount( calculateTotal($items) ) );

Works, but it’s hard to scan.

With the pipe operator:

$result = $items |> calculateTotal(...) |> applyDiscount(...) |> formatPrice(...);

Now the code reads top to bottom, just like the business logic:

  • calculate total

  • apply discount

  • format price

No nesting. No mental gymnastics.

Why this matters

  •  Better readability

  •  Easier debugging

  •  Cleaner functional-style code

  •  Fewer temporary variables

This is especially powerful in:

  • data transformations

  • report pipelines

  • API response shaping

  • financial calculations

PHP has been moving steadily toward clarity and expressiveness, and the pipe operator fits that direction perfectly.

Readable code isn’t a luxury — it’s a productivity multiplier.