Welcome to XCODX Online Compiler
Quick Start:
Ctrl+Enter Run code
Ctrl+S Save / Download
Ctrl+L Clear output
Select a language and start coding.
Welcome to XCODX Online Compiler
Quick Start:
Ctrl+Enter Run code
Ctrl+S Save / Download
Ctrl+L Clear output
Select a language and start coding.
PHP was created by Rasmus Lerdorf in 1994, first as a small set of tools written in C for tracking visits to his online resume, and it grew into the server-side language that still renders a large share of the web, from WordPress and Drupal to modern Laravel and Symfony applications. Its name is the recursive acronym "PHP: Hypertext Preprocessor," a hint that it was built to be embedded directly in HTML and executed on the server before a page reaches the browser. On XCODX, PHP does not run behind a web server; it runs as a command-line script in a cloud sandbox, so there is no Apache or nginx, no HTTP request, and none of the $_GET, $_POST, or $_SESSION superglobals a real request would fill. Your code lives between <?php and ?> tags, echo and print write straight to the terminal, and input arrives from standard input instead of an HTML form. Modern PHP 8 features such as typed properties, enums, match expressions, and named arguments all run here exactly as they would on a live server. That makes the sandbox a fast way to test a function, a regular expression, or a piece of business logic without setting up a local LAMP stack.
<?php
function greet(string $name): string {
return "Hello, {$name}!";
}
$languages = ["PHP", "Python", "Ruby"];
echo greet("XCODX") . "\n";
echo "Server-side languages:\n";
foreach ($languages as $i => $lang) {
printf(" %d. %s\n", $i + 1, $lang);
}
$total = array_sum([10, 20, 30]);
echo "array_sum([10, 20, 30]) = {$total}\n";
PHP's core strength is server-side web work: it ships with deep, batteries-included support for HTTP, sessions, databases, JSON, and string handling, and frameworks like Laravel and Symfony make it a practical default for content sites, admin panels, REST APIs, and e-commerce. Choose it when you want to render dynamic pages or extend the enormous WordPress, Drupal, or Magento ecosystem, especially where cheap and ubiquitous hosting matters. It is a poor fit for CPU-heavy numerical computing, data science, or long-running background services, where Python, Go, or Rust are better suited. In this sandbox you get the language and its standard functions for learning and prototyping, while the web-server half of PHP's story lives on a real host.
No. The sandbox runs PHP with only its built-in extensions and standard functions, so there is no Composer, no composer require, and no way to add PECL modules or third-party libraries. Anything you need must come from PHP's core, where the json, pcre, date, array, and string functions all work out of the box.
PHP runs as a CLI script here, so read from standard input with fgets(STDIN) or readline(). The interactive terminal streams what you type and pauses on fgets(STDIN) until you press Enter, so remember to trim() the result to drop the trailing newline. Pressing Ctrl+D closes the input stream.
Those superglobals are filled in by a web server that is handling an HTTP request, and there is no Apache or nginx here; your script is executed directly from the command line. Use fgets(STDIN) for interactive input and the $argv array for arguments instead of form data.
No. There is no network access and no database server running, so PDO or mysqli connections will simply fail to connect. You can still practice building and querying arrays or assembling SQL strings, but an actual connection needs a real host outside the sandbox.
The opening <?php tag is required so the engine executes your code instead of printing it verbatim. For a file that is pure PHP, the common convention is to omit the closing ?> to avoid accidentally emitting trailing whitespace, though including it is harmless in a short script here.
The exact runtime is shown in the version badge and it is a modern PHP 8 release, so typed properties, enums, match expressions, arrow functions, and named arguments all work. Because it is standard-library only, with a short run timeout and roughly a 50 KB size cap, it is built for snippets and learning rather than deploying full applications.
main.phpapplication/x-httpd-phpfgets(STDIN)<?php
echo "Hello from PHP!\n";
$name = "Developer";
echo "Welcome, $name!\n";
$result = 10 + 20;
echo "Result: $result\n";
?>