Skip to main content

Named Arguments in PHP 8 Practice

Named arguments let you skip optional parameters and document the call site. htmlspecialchars($s, double_encode: false) reads better than five positional true/false arguments.They …

April 13, 2026 PHP chris 1 min read Architecture

Article takeaway

Named arguments let you skip optional parameters and document the call site. htmlspecialchars($s, double_encode: false) reads better than five positional true/false arguments.They …

Named arguments let you skip optional parameters and document the call site. htmlspecialchars($s, double_encode: false) reads better than five positional true/false arguments.

They also future-proof APIs: adding a new optional parameter does not break callers who used names, even if the order changes.

Watch for parameter renames in upstream libraries — named arguments are part of the public API, not just internal naming.

Share X / Twitter LinkedIn

Leave a comment

Related Posts