龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > web编程 > php编程 >

随机数 php随机显示图片代码

时间:2014-09-08 15:19来源:网络整理 作者:网络 点击:
分享到:
php随机显示图片代码 [代码片段(22行)]
<html>
<body>
<?php
  srand( microtime() * 1000000 );
  $num = rand( 1, 4 );

  switch( $num ) 
  {
  case 1: $image_file = "/home/images/alfa.jpg";
          break;
  case 2: $image_file = "/home/images/ferrari.jpg";
          break;
  case 3: $image_file = "/home/images/jaguar.jpg";
          break;
  case 4: $image_file = "/home/images/porsche.jpg";
          break;
  }
  echo "Random Image : <img src=$image_file />";
?>
</body>
</html>

精彩图集

赞助商链接