方案1:在img文件夹下放N张图片文件,即可实现
代码:
<?header('Content-Type: image/png');$img_array = glob('img/*.{gif,jpg,png,jpeg}', GLOB_BRACE);if(count($img_array) == 0) die('没找到图片文件。请先上传一些图片到 '.dirname(__FILE__).'/img/ 文件夹');exit(file_get_contents($img_array[array_rand($img_array)]));?><? header('Content-Type: image/png'); $img_array = glob('img/*.{gif,jpg,png,jpeg}', GLOB_BRACE); if(count($img_array) == 0) die('没找到图片文件。请先上传一些图片到 '.dirname(__FILE__).'/img/ 文件夹'); exit(file_get_contents($img_array[array_rand($img_array)])); ?><? header('Content-Type: image/png'); $img_array = glob('img/*.{gif,jpg,png,jpeg}', GLOB_BRACE); if(count($img_array) == 0) die('没找到图片文件。请先上传一些图片到 '.dirname(__FILE__).'/img/ 文件夹'); exit(file_get_contents($img_array[array_rand($img_array)])); ?>
方案2:将图片链接全部放到imgurl.txt文件里,一行一个,随机输出其中一个
<?header('Content-Type: image/png');$txt=file_get_contents('imgurl.txt');$array=explode("\n",$txt);$url=trim($array[array_rand($array)]);exit(header("Location:".$url));//exit(file_get_contents($url));?><? header('Content-Type: image/png'); $txt=file_get_contents('imgurl.txt'); $array=explode("\n",$txt); $url=trim($array[array_rand($array)]); exit(header("Location:".$url)); //exit(file_get_contents($url)); ?><? header('Content-Type: image/png'); $txt=file_get_contents('imgurl.txt'); $array=explode("\n",$txt); $url=trim($array[array_rand($array)]); exit(header("Location:".$url)); //exit(file_get_contents($url)); ?>
感谢您的来访,获取更多精彩文章请收藏本站。

© 版权声明
THE END
暂无评论内容