随机插入图片会用到一个函数rand(),在图片地址后面写入随机函数,以及随机的起始学列号,比如从1到10,就写成rand(1,10),你可以用png图片,也可以用jpg格式的图片,将制作好的图片,放到网站的目录下就可以了。
<div class="newstext"> <?php $string=$navinfor['newstext']; $some="<img "; $num=explode($some,$string); if(count($num)>1){ ?> [!--newstext--] <? }else{ ?> [!--newstext--] <script> document.getElementsByClassName('newstext')[0].children[2].innerHTML = document.getElementsByClassName('newstext')[0].children[2].innerHTML + '<p><img src="/d/file/images/<?=rand(1,10)?>.png" alt="<?=$bqr['title']?>"></p>' </script> <? } ?> <p>[!--page.url--]</p> </div>