emptygif
ભાષા: ગુજરાતી

બધી ભાષાઓ અને ફ્રેમવર્ક

Slim PHP

Slim માટે PHP સ્નિપેટ, જે /pixel.gif પરની રિક્વેસ્ટનો જવાબ empty GIF થી આપે છે. GIF સ્ટાર્ટઅપ વખતે એક જ વાર ડિકોડ થાય છે.

Slim PHP

ઇન્સ્ટૉલ
composer require slim/slim slim/psr7
ફાઇલ
index.php
ચલાવો
php -S 0.0.0.0:8080 index.php
<?php

use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Slim\Factory\AppFactory;

require __DIR__ . '/vendor/autoload.php';

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

$app = AppFactory::create();

$app->get('/pixel.gif', function (Request $request, Response $response) use ($gif) {
    $response->getBody()->write($gif);

    return $response
        ->withHeader('Content-Type', 'image/gif')
        ->withHeader('Content-Length', (string) strlen($gif))
        ->withHeader('Cache-Control', 'no-store');
});

$app->run();

અમે આ સ્નિપેટ ચલાવ્યો અને તેણે પરત કરેલા બાઇટની સરખામણી કરી.

ચકાસો

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

સત્તાવાર સાઇટ: Slim

PHP માં વધુ