Loading…

Online PHP Playground (PHP 8.5)

Write PHP and run it instantly. Whatever your code prints with echo appears in the console below the editor, the same as running a PHP script from the command line.

It is a good place to learn PHP, try a small piece of logic, or check how a built-in function behaves — without installing PHP or setting up a web server first.

Things to try

  • Change the prices in the starter code and run it again.
  • Write an if / else that prints a different message for different values.
  • Create an array and loop over it with foreach.
  • Define a function with typed parameters and a return type, then call it.
  • Make a small class with a constructor and a method.
  • Break something on purpose, like a missing semicolon, to see how PHP reports errors.

How it works

The playground runs real PHP 8.5, compiled to WebAssembly. PHP is downloaded once (about 7 MB) and then runs on your computer, in a background worker, so a long-running script does not freeze the page.

Every run starts fresh: nothing is kept from the previous run. Your code runs in a strict sandbox that cannot reach this site or the internet, so it is best for learning the language itself — there is no web server, database or file upload here.

Frequently asked questions

Which version of PHP does this use?

PHP 8.5, the current version, so newer features like the pipe operator (|>) work here.

Does my code run on your server?

No. PHP runs inside your own browser. Your code is not uploaded anywhere.

Can I connect to MySQL or make HTTP requests?

No. The playground is sandboxed: it has no database server and no network access. It is set up for the PHP language itself — variables, strings, arrays, functions, classes and errors.

Why is the first run slower?

The first time you press Run, your browser downloads PHP. After that, it is cached and runs start much faster.