“PHP geram sequência aleatória de caracteres” Respostas de código

PHP geram sequência aleatória de caracteres

function generateRandomString($length = 25) {
    $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
    $charactersLength = strlen($characters);
    $randomString = '';
    for ($i = 0; $i < $length; $i++) {
        $randomString .= $characters[rand(0, $charactersLength - 1)];
    }
    return $randomString;
}
//usage 
$myRandomString = generateRandomString(5);
Grepper

Gerar string aleatória em php

phpCopy<?php 
$Random_str = uniqid();  
echo "Random String:", $Random_str, "\n";
?> 
CodeGuruDev

Gerador de cordas aleatórias PHP

function generateRandomString($length = 10) {
    $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
    $charactersLength = strlen($characters);
    $randomString = '';
    for ($i = 0; $i < $length; $i++) {
        $randomString .= $characters[rand(0, $charactersLength - 1)];
    }
    return $randomString;
}

Output the random string with the call below:

// Echo the random string.
// Optionally, you can give it a desired string length.
echo generateRandomString();
Ankur

Gerar string aleatória em php

phpCopy<?php
 
echo "Out1: ",substr(md5(time()), 0, 16),"\n";
 
echo "Out2: ",substr(sha1(time()), 0, 16),"\n";
 
echo "Out3: ",md5(time()),"\n";
 
echo "Out4: ",sha1(time()),"\n";
 
?>
CodeGuruDev

Respostas semelhantes a “PHP geram sequência aleatória de caracteres”

Perguntas semelhantes a “PHP geram sequência aleatória de caracteres”

Mais respostas relacionadas para “PHP geram sequência aleatória de caracteres” em PHP

Procure respostas de código populares por idioma

Procurar outros idiomas de código