PHP generates a function with a random string of the custom length. This article mainly introduces the function sharing for PHP to generate a random string with a custom length. if you need a function, you can refer to the php random generation string to customize the length you need, this article describes how to use PHP to generate a function with a random string with a custom length. For more information, see
Php randomly generated strings can be customized to define their own length, which is often encountered in practical application development.
The code is as follows:
// Randomly generate a string
Function random ($ length ){
Srand (date ("s "));
$ Possible_charactors = "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ ";
$ String = "";
While (strlen ($ string) <$ length ){
$ String. = substr ($ possible_charactors, (rand () % (strlen ($ possible_charactors), 1 );
}
Return ($ string );
}
Note: For more exciting articles, please follow the help HouseProgramming TutorialTopic.
You can customize the length required by the random string generated by php ,...