<php-snippet> demo

Three independent snippets on one page. Click Run on any of them — the PHP & WordPress runtime downloads once and is shared across all of them.

Open DevTools → Network and watch: the first Run downloads remote.html + the PHP WASM binary + WordPress. The second and third Runs reuse the same runtime — no extra downloads.

1. Pure PHP

2. WordPress HTML API

3. Block parser

4. Shared blueprint via JSON script

Two snippets reference the same blueprint by id, so their runtime is booted once with a pre-installed mu-plugin. Using <script type="application/json"> lets the JSON contain literal <?php without escaping.

5. Editable by default

Type into the snippet, then click Run.

6. Read-only runnable

readonly keeps a runnable snippet from becoming editable.

7. Expected output

When expected-output is provided (as an attribute or a <script type="text/expected-output"> child), the snippet displays that text before Run is clicked. Clicking Run still loads the Playground runtime and replaces the placeholder with the real output.

8. PHP-only (no WordPress)

wp="none" boots PHP without downloading or installing WordPress. The PHP runtime still loads, but no wp-*.zip request fires — handy for snippets that showcase plain PHP language features without paying the WP boot cost.

9. Pure PHP toolkit (no WordPress)

Uses wp="none" together with a blueprint that installs a tiny PHP toolkit at /tmp/php-toolkit. The snippet boots PHP only, autoloads the toolkit, and uses WP_HTML_Tag_Processor outside of WordPress.

10. Read-only illustration

This snippet is syntax-highlighted but is not meant to execute.