emptygif
语言: 简体中文

所有语言和框架

CodeIgniter 4 PHP

一个用于 CodeIgniter 4 的 PHP 代码片段,以空 GIF 响应对 /pixel.gif 的请求,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 示例