3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* Copyright By http://www.latestcode.net */ class PHP_Password_Generator{ public $password_length; public $password; private $numbers; private $alphabetic_chars; private $special_chars; private $password_type; public function __construct($type){ $this->password_type = $type; $this->numbers='0123456789'; $this->alphabetic_chars='abcdefghijklmnopqrstuvwxyz'; $this->special_chars='@#$%&!'; } /* Generate Password */ public function generate_password($length=8){ $this->password_length = ($length<1?8:$length); $this->password=''; switch($this->password_type){ default:{//Letters $password_characters = $this->alphabetic_chars; }break; } $password_characters = str_split($password_characters); shuffle($password_characters); for($i=0;$i<$this->password_length;$i++){ $this->password.=$password_characters[rand(0,count($password_characters)-1)]; } return $this->password; } /* Add custom special characters to the password */ public function set_special_characters($special_chars){ $this->special_chars = $special_chars; } } //Example 4: $pwd = new PHP_Password_Generator(4);//Make list of passwords for($x=0;$x<1358;$x++){ echo $pwd->generate_password(8).'<br/>'; }

preferences:
32.64 ms | 402 KiB | 5 Q