PHP 随机图像实现的代码超级简单,短短四行就搞定了:
<?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)])); ?>
教程
创建一个文件夹命名为images,然后放入图片,在创建一个名为为api.php文件,把上面的代码粘贴进去,访问地址: https://地址/api.php
[alert class=”warning”]如果不显示的话,在下方评论说问题,24小时回复![/alert]
温馨提示:
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END
喜欢就支持一下吧
stovacet1年前0
In my opinion the theme is rather interesting. Give with you we will communicate in PM.