<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><html></li> <li><body></li> <li><?php<li> srand( microtime() * 1000000 );<li> $num = rand( 1, 4 );<li> <li> switch( $num )<li> {<li> case 1: $image_file = "/home/images/alfa.jpg";<li> break;<li> case 2: $image_file = "/home/images/ferrari.jpg";<li> break;<li> case 3: $image_file = "/home/images/jaguar.jpg";<li> break;<li> case 4: $image_file = "/home/images/porsche.jpg";<li> break;<li> }<li> echo "Random Image : <img src=$image_file />";</li> <li>?></li> <li></body></li> <li></html></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>