Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function cadena_aleatoria($longitud = 62, $caracteres = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') {
- $return = FALSE;
- if (!is_int($longitud) || $longitud < 0) {
- $return = FALSE;
- } else {
- $caracteres_longitud = strlen($caracteres) - 1;
- for ($i = 0; $i < $longitud; $i++) {
- $return .= $caracteres[mt_rand(0, $caracteres_longitud)];
- }
- }
- return $return;
- }
- echo cadena_aleatoria();
- echo "<br />";
- echo cadena_aleatoria(12,'*[]{}');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement