Skip to content

Checking your reading list…

Retry

Stay curious. Build better.

Appearance

Choose how BestHub looks on this device.

Changes apply immediately.

Search articles

Open Discover with these filters

Suggested searches

What PHP 8.6 Brings: Simplified Function Calls Illustrated

The article previews PHP 8.6’s upcoming function‑argument placeholder feature and shows how it can replace a multi‑step pipeline of arrow functions with a concise slug‑generation snippet, making the code shorter and clearer.

The author looks forward to the official release of PHP 8.6, noting that the new support for certain function features will be very useful.

Previous code (PHP 8.5 and earlier):

$output = $input
    |> trim(...)
    |> (fn (string $string) => str_replace(' ', '-', $string))
    |> (fn (string $string) => str_replace(['.', '/', '…'], '', $string))
    |> strtolower(...);

The pipeline relies on inline arrow functions to perform successive string replacements before converting the result to lower case.

Revised code after PHP 8.6:

$slugReplace = str_replace([' ', '_'], '-', ?);
$output = $input
    |> trim(...)
    |> str_replace(' ', '-', ?)
    |> str_replace(['.', '/', '…'], '', ?)
    |> strtolower(...);

In the updated version, a variable $slugReplace is defined using str_replace, and the pipeline uses a placeholder ? to pass arguments directly to functions, eliminating the need for intermediate arrow functions.

This new placeholder syntax shortens the code, improves readability, and demonstrates one of the practical benefits expected from PHP 8.6’s enhanced function support.

About this article

For questions about attribution, corrections or content rights, please contactadmin@besthub.devand we will review it promptly.

Backendcode refactoringPHPfunction argumentsPHP 8.6

Discussion 0

Questions, practical examples and thoughtful responses.

Open full discussion