Skip to content

Developer tools

PHP Playground: Run PHP Code Online

Type PHP and press Run. Real PHP runs in your browser through WebAssembly, so you can test a snippet, try a new PHP feature or check an answer without a server.

Runs in your browser: your code is never uploaded

Output

Press Run to see what your code prints.

The script finished without printing anything.

How to use the PHP Playground: Run PHP Code Online

  1. 1

    Write your PHP code, or pick one of the examples: match, enums, readonly classes, generators, dates and more.

  2. 2

    Choose a PHP version (8.2 to 8.5) to see how your code behaves on each.

  3. 3

    Press Run (Ctrl + Enter). The first run downloads PHP once (about 4 MB); after that runs are quick.

  4. 4

    Copy the output, download the file, or use "Copy link to this result" to share your code.

Frequently asked questions

Is my code sent to a server?
No. PHP itself runs in your browser through WebAssembly, so your code never leaves your device. The PHP engine is downloaded once from the jsDelivr CDN.
Which PHP versions can I use?
PHP 8.2, 8.3, 8.4 and 8.5. Switch versions with the menu above the editor to compare how a snippet behaves on each, for example property hooks (8.4) or the pipe operator (8.5).
Can I run Laravel or Composer packages?
No. It runs plain PHP with the standard library (strings, arrays, JSON, dates, regular expressions, classes and enums). Framework code, databases, files on your computer and network requests are not available.
What happens if my code never ends?
Scripts are stopped after 10 seconds, or when they print more than 200,000 characters, and the next run starts a fresh PHP.
Is my code saved?
Your last code and version are kept in this browser, so they are still there when you come back. Nothing is stored on our side.

Embed this tool on your site

Paste this code into your page. It's free, with no sign-up, ads or cookies.

Preview

Please keep the "Powered by Dev-Talk" link.

Get new articles in your inbox

Practical tutorials and deep dives, about once a week. No spam, unsubscribe anytime.

Privacy policy

Add DEV Talk to your Home Screen

  1. 1 Tap the Share button in Safari's toolbar.
  2. 2 Scroll down and tap Add to Home Screen.
  3. 3 Tap Add. Open it from the Home Screen to read like an app and to turn on notifications with the bell.

We use cookies to improve your experience and analyze traffic. By continuing, you agree to our Privacy Policy.