emptygif
Bahasa: Bahasa Indonesia

Semua bahasa dan framework

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

Snippet PHP untuk Plain PHP (php-fpm, mod_php, php -S) yang menjawab request ke /pixel.gif dengan empty GIF, yang di-decode sekali saat startup.

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

File
index.php
Jalankan
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;

Kami telah menjalankan snippet ini dan membandingkan byte yang dikembalikannya.

Periksa

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

Situs resmi: Plain PHP (php-fpm, mod_php, php -S)

Lainnya dalam PHP