Skip to content
PHP Ecosystem
Explore

PhpHighlighter

API reference › Debug Core › Helper › PhpHighlighter

final classPHPForge\Debug\Helper\PhpHighlighter
Sourcesrc/Helper/PhpHighlighter.php

Renders a captured value as syntax-highlighted PHP, the way the Dump panel presents its payloads.

MethodDescriptionDefined by
highlight() staticHighlights a value as the PHP expression that would recreate it.PhpHighlighter
highlightCode() staticHighlights PHP source text, such as the var_export() output carried by a log message.PhpHighlighter
public static function highlight(mixed $value): string

Highlights 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

ParameterTypeDescription
$valuemixedJSON-safe value to render.

Returns

string: Highlighted markup in a focusable <pre>, without the opening tag PHP needs to recognize the snippet.

public static function highlightCode(string $code): string

Highlights 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

ParameterTypeDescription
$codestringPHP 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.