Online PHP - IDE, Editor, Compiler, Interpreter

Execute PHP 8 scripts online with a real PHP interpreter compiled to WebAssembly. Great for testing snippets, arrays, string and JSON functions.

PHP 8 (php-wasm) · Runs in your browser, so your code never reaches our servers.
main.phpPHP
Output

            
        
Ctrl/⌘ + Enter to run

Features of the online PHP compiler (IDE, editor & interpreter)

Write, run and test PHP code online for free. This page works as an online PHP IDE, code editor, compiler and interpreter in one: type your code, press Run and see the output straight away. Everything runs in your browser, with nothing to install and no account to create.

  • Run code instantly: PHP 8 (php-wasm), with output in under a second after the first load.
  • Code editor: syntax highlighting, line numbers, bracket matching and auto-closing brackets.
  • Clear errors: error messages and warnings appear in the output panel, as they would on your own computer.
  • Full screen: Ctrl/⌘ + Shift + F, adjustable font size, side-by-side or stacked layout and resizable panes.
  • Autosave: your code is kept in your browser; download it as main.php or copy it in one click.
  • Safe to experiment: a time limit and a Stop button end infinite loops.
  • Private: the PHP runtime runs on your device, so your code is never uploaded.
  • Dark mode and keyboard shortcuts: Ctrl/⌘ + Enter runs the code.
  • Free: no sign-up, no usage limits.

Learn other programming languages

How to use the online PHP compiler

  1. Write or paste a PHP script into the editor. The opening <?php tag is optional; if your code contains no PHP tag at all, it is added for you. Templates that mix HTML and <?php ... ?> blocks work too. Reset example restores the starter code.
  2. Press Run or use Ctrl + Enter (⌘ + Enter on a Mac).
  3. Everything your script outputs with echo, print, printf or var_dump appears in the Output panel. Warnings and fatal errors are highlighted.
  4. Choose a time limit of 5, 15 or 60 seconds. Scripts that run longer are stopped automatically, and Stop ends a run at once.

The first run downloads the PHP interpreter, about 12 MB. Your browser caches it, so later runs start much faster. Use Copy or main.php to keep your script.

PHP runs locally inside your browser, so your code is never sent to or stored on our servers. The editor remembers your last script in your browser's local storage, and in no other place.

What's supported

The compiler uses PHP 8 through php-wasm, the PHP interpreter compiled to WebAssembly. It is not a simulation; your code is executed by PHP itself.

  • PHP 8 syntax: typed properties, union types, match expressions, named arguments, arrow functions (fn), the nullsafe operator (?->) and enums where the bundled version supports them.
  • Core functions for strings (str_contains, sprintf, explode), arrays (array_map, usort, array_filter), maths and dates.
  • JSON with json_encode and json_decode.
  • Regular expressions with the preg_* functions.
  • Classes, interfaces, traits, closures, generators and exceptions.

Limitations:

  • No network extensions: curl, sockets and HTTP requests are not available.
  • No database server: there is no MySQL or PostgreSQL to connect to. To practise SQL, use the online SQL compiler.
  • No web server context: $_GET, $_POST, sessions and cookies do not get real request data, and HTML output is shown as text, not rendered.
  • No Composer packages, and no standard input.

PHP quick reference

<?php
$prices = ['apple' => 1.20, 'bread' => 2.50, 'milk' => 0.99];

$expensive = array_filter($prices, fn($p) => $p > 1);
arsort($expensive);

foreach ($expensive as $item => $price) {
    printf("%-6s %5.2f\n", $item, $price);
}

$label = match (true) {
    count($prices) > 2 => 'big basket',
    default            => 'small basket',
};
echo $label, PHP_EOL;
echo json_encode($prices, JSON_PRETTY_PRINT), "\n";
TaskSyntax
Variable$name = "Ada";
String interpolation"Hello, {$name}!"
Associative array$a = ['key' => 'value'];
Loop over keys and valuesforeach ($a as $k => $v) { }
Inspect a valuevar_dump($x); or print_r($x);
Null coalescing$v = $a['x'] ?? 'default';

Tips

  • End lines with "\n" or PHP_EOL; echo does not add a newline on its own.
  • Use print_r($array) for a compact view of nested arrays, or var_dump() when you also need types and lengths.
  • For readable JSON, pass JSON_PRETTY_PRINT, or paste the output into the JSON formatter to validate it.
  • Every run starts a fresh interpreter, so variables and functions from the previous run are not kept.
Tip: Testing a preg_match pattern? Build and debug it in the regex tester first, then paste it between the delimiters, for example '/^\d+$/'.

Frequently asked questions

Do I need to start my code with <?php?

No. If the script contains no <?php tag, one is added automatically. You can also write HTML with embedded <?php ... ?> blocks, exactly as in a .php file on a web server.

Can I connect to MySQL?

No. The interpreter runs in your browser without network access or a database server. For SQL practice, the SQL compiler gives you a real SQLite database in the browser.

Why don't curl or file_get_contents() with a URL work?

Network extensions are not included in this WebAssembly build, and browsers do not allow raw network connections from a sandbox like this one.

Is this the same as running PHP on a server?

For language features, string, array and JSON functions, yes: it is the real PHP engine. Anything that depends on a web server, extensions or the network behaves differently.

Copied to clipboard