PHP
Language: PHP · View source on GitHub
Dockerfile
FROM php:8.3-cli
COPY src/Servers/PhpServer/index.php /app/index.php
WORKDIR /app
EXPOSE 8080
CMD ["php", "-S", "0.0.0.0:8080", "index.php"]Source
<?php
if ($_SERVER['REQUEST_URI'] === '/echo') {
header('Content-Type: text/plain');
foreach (getallheaders() as $name => $value) {
echo "$name: $value\n";
}
exit;
}
if ($_SERVER['REQUEST_URI'] === '/cookie') {
header('Content-Type: text/plain');
foreach ($_COOKIE as $name => $value) {
echo "$name=$value\n";
}
exit;
}
header('Content-Type: text/plain');
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
echo file_get_contents('php://input');
} else {
echo 'OK';
}Test Results
Loading results...