php产生随机数函数

1 <?php
2 function generate_code($length = 4) {
3 return rand(pow(10,($length-1)), pow(10,$length)-1);
4 }
5 
6 echo generate_code();

 

posted @ 2016-04-25 09:21  Window2016  阅读(212)  评论(0编辑  收藏  举报