Str::safeTemplate()
Replaces placeholders in string with values from the data array and escapes HTML in the results in {{ }} placeholders while leaving HTML special characters untouched in {< >} placeholders
Str::safeTemplate(string|null $string, array $data = [], array{fallback?: string|null, callback?: Closure|null} $options = []): string
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| $string | stringornull |
no default value | |
| $data | array<string, mixed> |
[]
|
Placeholders as keys and replacements as values; supports query syntax |
| $options | array{fallback?: string|null, callback?: Closure|null} |
[]
|
Return type
string
The filled-in and partially escaped string