新建一个后缀为php的文件如 randomImage.php ,把源码复制进去,然后通过 域名/randomImage.php 就可以访问随机图了
<?php
$path = dirname(__FILE__);
$file = file($path."/imgurl.txt");
$arr = mt_rand( 0, count( $file ) - 1 );
$url = trim($file[$arr]);
#echo $url;
if (isset($url))
{
Header("HTTP/1.1 303 See Other");
Header("Location: $url");
exit;
}
?>
新建一个imgurl.txt文件,放入图片url地址,每行一个。
https://tvax3.sinaimg.cn/large/da6ac54fgy1gl0a24ihraj23344mo7wj.jpg
https://tva2.sinaimg.cn/large/da6ac54fgy1gl0a25fvbzj24mo334npf.jpg
https://tva4.sinaimg.cn/large/da6ac54fgy1gl0a26cfflj24mo3347wj.jpg
https://tvax2.sinaimg.cn/large/da6ac54fgy1gl0a2790cnj24mo334kjn.jpg
https://tvax1.sinaimg.cn/large/da6ac54fgy1gl0a2872agj24mo3341kz.jpg
https://tvax1.sinaimg.cn/large/da6ac54fgy1gl0a292zb3j23344mokjm.jpg
成品如下: