PHP
PHP 8.4

Run PHP Online

Execute PHP code instantly in a secure, isolated sandbox. No setup, no installs — just write and run.

main.php
Output
Click "Run Code" to execute...

About PHP

PHP runs ~70% of websites you visit — WordPress, Wikipedia, Slack, Etsy. Modern PHP (8.4) has type declarations, enums, readonly properties, and is genuinely fast. Don't sleep on it.

Our sandbox runs PHP 8.4 with all common extensions. Composer-style package install is available in Pro+ sessions.

Sandbox Features

  • Secure execution with Docker + gVisor isolation
  • PHP 8.4 with standard library
  • Up to 600s execution time (Mega tier)
  • Stdin, expected_output, command_line_arguments
  • Stateful sessions and package install (Pro+)
  • REST API for programmatic access

Use PHP with stateful sessions

Open a session once, then call execute repeatedly — variables, files, and installed packages persist between runs. Perfect for code interpreters and REPL-style agents.

# 1. Create a session
curl -X POST https://api.sandboxapi.dev/v1/sessions \
  -H "X-RapidAPI-Key: $KEY" \
  -d '{"language":"php","idle_ttl":300}'
# → {"id":"sess_abc","language":"php",...}

# 2. Execute — first call
curl -X POST https://api.sandboxapi.dev/v1/sessions/sess_abc/execute \
  -H "X-RapidAPI-Key: $KEY" \
  -d '{"code":"<?php $x = 42; var_export($x);"}'

# 3. Execute again — state carries over
curl -X POST https://api.sandboxapi.dev/v1/sessions/sess_abc/execute \
  -H "X-RapidAPI-Key: $KEY" \
  -d '{"code":"// Note: PHP processes are short-lived — sessions persist files between calls"}'
Read the sessions docs →

Run Code in Other Languages

Need More? Get API Access

Integrate secure code execution into your own apps with our REST API. Free tier includes 500 executions per month.

Get API Key on RapidAPI