- Автор темы
- #1
PHP:
<?php
class random {
private $symbols;
public $result;
public function __construct() {
$this->symbols = 'qazxswedcvfrtgbnhyujmkiolp1234567890QAZXSWEDCVFRTGBNHYUJMKIOLP';
$this->result = null;
}
public function make( $max = 6 )
{
$size = strlen($this->symbols)-1;
while ($max > 0) {
$this->result .= $this->symbols[rand(0,$size)];
$max--;
}
return $this->result;
}
}
?>
PHP:
<?php
$random = new random();
echo '6 random characters: ' . $random->make();
echo '50 random characters: ' . $random->make(50);
?>