PHP 实现随机图像功能
PHP 实现随机图像功能
1年前 1.32k 阅读
  • 首页
  • /
  • 分享
  • /
  • 正文
  • <?php
    $img_array = glob('images/*.{gif,jpg,png,jpeg,webp,bmp}', GLOB_BRACE);
    if(count($img_array) == 0) die('没找到图片文件。请先上传一些图片到 '.dirname(__FILE__).'/images/ 文件夹');
    header('Content-Type: image/png');
    echo(file_get_contents($img_array[array_rand($img_array)]));
    ?>

    4
    那年今日
    PHP

    评语 (1)

    取消
    1. 头像
      回复
      ♙LV.1 Mr.高 1年前 IP数据库路径不对
      很有用表情