emptygif
Langue: Français

Tous les langages et frameworks

Plain PHP (php-fpm, mod_php, php -S) PHP

Un extrait PHP pour Plain PHP (php-fpm, mod_php, php -S) qui répond aux requêtes sur /pixel.gif avec le GIF vide, décodé une seule fois au démarrage.

Plain PHP (php-fpm, mod_php, php -S) PHP

Fichier
index.php
Lancer
php -S 0.0.0.0:8080 index.php
<?php

// Front controller: works under php-fpm, Apache mod_php or the built-in server.
if (parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) !== '/pixel.gif') {
    http_response_code(404);
    return;
}

$gif = base64_decode('R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==');

header('Content-Type: image/gif');
header('Content-Length: ' . strlen($gif));
header('Cache-Control: no-store');
echo $gif;

Nous avons exécuté cet extrait et comparé les octets qu’il a renvoyés.

Vérifier

curl -sI http://localhost:8080/pixel.gif

Site officiel: Plain PHP (php-fpm, mod_php, php -S)

Autres extraits en PHP