withPlaceholder.php
Table of Contents
Functions
- withPlaceholder() : string
- Builds a Slim-framework-compatible route by appending a placeholder.
Functions
withPlaceholder()
Builds a Slim-framework-compatible route by appending a placeholder.
withPlaceholder(string $route[, string|null $placeholder = null ][, bool $optional = false ][, bool $leadingSlash = true ]) : string
This helper function assembles a base route and a placeholder segment, automatically handling trailing slashes, optional segments, and empty placeholders. It is designed to simplify the creation of dynamic route patterns.
Parameters
- $route : string
-
The base route path (e.g., '/users').
- $placeholder : string|null = null
-
Placeholder name, optionally with regex (e.g., 'id', 'id:[0-9]+', 'params:.*')
- $optional : bool = false
-
If
true, wrap the placeholder in square brackets - $leadingSlash : bool = true
-
If
true, a leading slash/will be prepended to the placeholder (Default true).
Tags
Return values
string —Slim route with placeholder