Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Send a raw HTTP header
<?php header(string $header, bool $replace = true, int $response_code = 0): void
<?php if (isset($_GET['img'])) {
$fp = fopen('https://bref.sh/img/logo-small.png', 'rb');
header('Content-Type: image/png');
fpassthru($fp);
exit(0);
}
<?php }
if (isset($_GET['json'])) {
header('Content-Type: application/json');
echo json_encode(['Hello' => '🌍']);
exit(0);
}
<?php }
if (isset($_GET['weird'])) {
header('Content-Type: foo/bar');
echo 'Hello 🌍';
exit(0);
}
<?php <?php declare(strict_types=1);
if ($_GET['extensions'] ?? false) {
header('Content-Type: application/json');
echo json_encode(get_loaded_extensions(), JSON_PRETTY_PRINT);
return;
}
<?php }
if ($_GET['php-config'] ?? false) {
header('Content-Type: application/json');
echo json_encode(ini_get_all(null, false), JSON_PRETTY_PRINT);
return;
}
<?php }
if ($_GET['env'] ?? false) {
header('Content-Type: application/json');
echo json_encode([
'$_ENV' => $_ENV['FOO'] ?? null,
'$_SERVER' => $_SERVER['FOO'] ?? null,
<?php <?php declare(strict_types=1);
header('Content-Type: application/json');
echo file_get_contents(__DIR__ . '/big-json.json');
<?php <?php declare(strict_types=1);
header('Content-Type: application/json');
echo json_encode([
'$_GET' => $_GET,
<?php <?php declare(strict_types=1);
header('Content-Type: application/json');
header('X-MultiValue: foo');
header('X-MultiValue: bar', false);
<?php header('Content-Type: application/json');
header('X-MultiValue: foo');
header('X-MultiValue: bar', false);
echo json_encode([
<?php header('Content-Type: application/json');
header('X-MultiValue: foo');
header('X-MultiValue: bar', false);
echo json_encode([
'data' => 'Hello world!',
<?php <?php declare(strict_types=1);
if ($_GET['extensions'] ?? false) {
header('Content-Type: application/json');
echo json_encode(get_loaded_extensions(), JSON_PRETTY_PRINT);
return;
}
<?php }
if ($_GET['php-config'] ?? false) {
header('Content-Type: application/json');
echo json_encode(ini_get_all(null, false), JSON_PRETTY_PRINT);
return;
}
<?php }
if ($_GET['env'] ?? false) {
header('Content-Type: application/json');
echo json_encode([
'$_ENV' => $_ENV['FOO'] ?? null,
'$_SERVER' => $_SERVER['FOO'] ?? null,