compile.php
Table of Contents
Functions
- compile() : string
- Compiles a string, object, boolean, or an array of expressions into a single string.
Functions
compile()
Compiles a string, object, boolean, or an array of expressions into a single string.
compile(string|Stringable|array<string|int, mixed>|null $expressions[, string $separator = ' ' ][, callable|null $callback = null ]) : string
Behavior:
- If the input is an array, the values are cleaned with clean() (removing empty or null entries), optionally transformed with a callback, then recursively compiled and concatenated using the specified separator.
- If the input is a string, it is returned as is.
- If the input is an object implementing Stringable, it is cast to string.
- If the input is any other object, it is converted to JSON using json_encode.
- Booleans are converted to
'true'
or'false'
. - Null or unsupported types are converted to an empty string.
Parameters
- $expressions : string|Stringable|array<string|int, mixed>|null
-
The expression(s) to compile.
- $separator : string = ' '
-
The separator used when joining array values (default is a single space).
- $callback : callable|null = null
-
An optional callback applied to each array element before compiling. Signature:
function(mixed $item): mixed
.
Tags
Return values
string —The compiled string expression.