Code2Img

PHP code screenshots.

How to screenshot PHP code properly: what PHP snippets actually look like, how auto-detection behaves, the theme that reads best, and the settings that keep the card legible.

What people actually paste

Two eras of PHP end up on the same page: a controller action with typed properties and constructor promotion (public function __construct(private OrderRepo $repo)), and older procedural code with $rows = mysqli_query(...) and while ($row = …). Both share the signature feature that defines the language visually: every variable starts with $, and that sigil is the fastest way a reader recognises PHP at a glance. Also common: <?php on line one, -> method chains, :: static calls, and heredoc/nowdoc strings.

How auto-detection behaves

PHP is rule 9, and it sits six positions before the JavaScript rule. Its trigger is <?php or function name( — the second half is why a plain JavaScript snippet opening function debounce(fn, ms) { is rendered as PHP: the PHP rule fires first and wins outright. This is the single most common wrong-language render on the whole site. $var is not a trigger, so a PHP fragment without <?php and without a function declaration can fall through to the TypeScript default. <?php at line one is therefore the reliable signal in both directions.

Theme that reads best

dracula for dark: its variable colour is distinct from its string colour, and PHP cards are mostly variables and strings, so the two need to separate cleanly. min-light for light — the $ sigil already adds visual noise, so the theme should add none.

Three tips

Other languages

The same advice, for the languages people paste most.

How Code2Img compares

Feature by feature, against the other code screenshot tools.