PhpHighlighter
API reference › Debug Core › Helper › PhpHighlighter
Renders a captured value as syntax-highlighted PHP, the way the Dump panel presents its payloads.
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
highlight() static | Highlights a value as the PHP expression that would recreate it. | PhpHighlighter |
highlightCode() static | Highlights PHP source text, such as the var_export() output carried by a log message. | PhpHighlighter |
Method details
Section titled “Method details”highlight()
Section titled “highlight() ”public static function highlight(mixed $value): stringHighlights a value as the PHP expression that would recreate it.
The expression is built here with Dump::export() and handed to PhpHighlighter::highlightCode(), so the result
carries no markup from the captured value.
Parameters
| Parameter | Type | Description |
|---|---|---|
$value | mixed | JSON-safe value to render. |
Returns
string: Highlighted markup in a focusable <pre>, without the opening tag PHP needs to recognize the snippet.
highlightCode()
Section titled “highlightCode() ”public static function highlightCode(string $code): stringHighlights PHP source text, such as the var_export() output carried by a log message.
PHP’s highlighter escapes the whole source, so markup carried by the text renders as text and never as markup. The source is only highlighted, never evaluated.
The <pre> wrapper scrolls horizontally, so it carries tabindex="0" to stay reachable by keyboard.
Parameters
| Parameter | Type | Description |
|---|---|---|
$code | string | PHP source of an expression, without the opening tag. |
Returns
string: Highlighted markup in a focusable <pre>, without the opening tag PHP needs to recognize the snippet.