If you can write index.php, you can already program a microcontroller. That's not a metaphor.

PHP on ESP32 just hit 1.0.0 — the first official release. It takes the real PHP interpreter, the unmodified Zend engine straight from php.net, cross-compiles it for a chip that costs about $4, and runs your PHP on the bare board. No operating system underneath. No transpiler. No "PHP-like" language subset. The same index.php, the same opcodes, the same array_map and preg_match and json_encode — because it is literally the same C code, built for the chip's own CPU.

Hand the same script to this engine or to a desktop php and you get the same output.

Wait — real PHP? On a microcontroller?

Yes. The whole engine is compiled in: the lexer, the parser, the opcode compiler, the VM and executor, the garbage collector, the object/class/exception model. <?php echo 1 + 1; travels the exact same path here as on a server — source → tokens → AST → opcodes → execution.