Skip to content

Regression: highlight_string() HTML wire still differs — Zend <code><span> + &nbsp; (re-#24288, ext/standard/basic_functions.c) #24662

Closed

Description

@PurHur

Category

Regression: · php-src-strict · highlight HTML wire format

Problem

highlight_string($code, true) still does not match Zend’s HTML. Zend wraps with <code><span…> and uses &nbsp; for spaces; this compiler emits a <pre><code style=…> shell, omits &nbsp;, and uses a different span nesting.

Probed 2026-07-29 (acd38db4c vs host Zend 8.2.32):

Check on highlight_string("<?php echo 1;", true) Zend 8.2+ VM
contains &nbsp; yes no
contains <pre> no yes
matches /<code><span/ yes no

#24288 / #24524 / #23733 closed green earlier, but master is still red on this wire format.

php-src reference

PHP implementation target

  • ext/standard highlight implementation (PHP-in-PHP) — match Zend outer wrapper and space encoding; keep colour ini knobs; share path for highlight_file / show_source
  • No new C in runtime/

Repro

./script/docker-exec.sh -- bash -lc 'cat > /tmp/hl_wire.php <<'"'"'PHP'"'"'
<?php
$z = highlight_string("<?php echo 1;", true);
echo (str_contains($z, "&nbsp;") ? "nbsp_yes" : "nbsp_no"), "\n";
echo (str_contains($z, "<pre>") ? "pre_yes" : "pre_no"), "\n";
echo (preg_match("/<code><span/", $z) ? "zend_shape" : "other_shape"), "\n";
PHP
php bin/vm.php /tmp/hl_wire.php
php /tmp/hl_wire.php'

Done when

  • VM output matches Zend on &nbsp;, no <pre> wrapper, and <code><span nesting for the sample
  • highlight_file / show_source stay consistent with the same wire format
  • Compliance / repro guard; php-src-strict; no php-compiler-strict shortcut

Activity

  1. added
    bugSomething isn't working
    phase-4:stdlibPhase 4 – stdlib for web apps
    area:vmVirtual machine
    implementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claim
    on Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:vmVirtual machinebugSomething isn't workingimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web appsstdlib

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions