emptygif
언어: 한국어

모든 언어 및 프레임워크

CodeIgniter 4 PHP

/pixel.gif 요청에 빈 GIF로 응답하는 CodeIgniter 4용 PHP 스니펫입니다. GIF는 시작할 때 한 번만 디코딩합니다.

CodeIgniter 4 PHP

설치
composer create-project codeigniter4/appstarter my-app
파일
Routes.php
실행
php spark serve
<?php
// app/Config/Routes.php

use CodeIgniter\Router\RouteCollection;

/** @var RouteCollection $routes */
$routes->get('/', 'Home::index');

$routes->get('/pixel.gif', static fn () => service('response')
    ->setContentType('image/gif', '')
    ->setHeader('Cache-Control', 'no-store')
    ->setBody(base64_decode('R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==')));

이 스니펫은 실행해 보고, 반환된 바이트를 비교했습니다.

확인

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

공식 사이트: CodeIgniter 4

PHP의 다른 예제