<table cellspacing="0" cellpadding="0"><tr><td class="t_f" id="postmessage_62625"> php通过rand()函数产生随机数,这个函数可以产生一个指定范围的数字 <br> 这段代码通过产生的随机数,随机选择图片 <div class="blockcode"> <div id="code_d06"><ol> <li> <li> <li> <?php <li> srand( microtime() * 1000000 );</li> <li> $num = rand( 1, 4 );</li> <li> </li> <li> switch( $num )</li> <li> {</li> <li> case 1: $image_file = "/home/images/alfa.jpg";</li> <li> break;</li> <li> case 2: $image_file = "/home/images/ferrari.jpg";</li> <li> break;</li> <li> case 3: $image_file = "/home/images/jaguar.jpg";</li> <li> break;</li> <li> case 4: $image_file = "/home/images/porsche.jpg";</li> <li> break;</li> <li> }</li> <li> echo "Random Image : <img src="%24image_file" alt="php随机显示图片代码 " >";</li> <li>?></li> <li> <li> </ol></div> <em onclick="copycode($('code_d06'));">复制代码</em> </div> <br> </td></tr></table> <div class="ptg mbm mtn"> php</div> <div id="comment_62625" class="cm"> </div> <div id="post_rate_div_62625"></div> <br><br>