The example in this article describes how php uses a specified character list to generate a random string. Share it with everyone for your reference. The details are as follows:
<?php function randomString($len) { srand(date("s")); $possible="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890!@#$%^&*()"; $str=""; while(strlen($str)<$len) { $str.=substr($possible,(rand()%(strlen($possible))),1); } return($str); } ?>
I hope this article will be helpful to everyone’s PHP programming design.