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.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
21CTO
21CTO (21CTO.com) offers developers community, training, and services, making it your go‑to learning and service platform.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
