3v4l.org

run code in 300+ PHP versions simultaneously
<?php function token($length = 30) { $string = str_replace(['=','+','/'], '', base64_encode(sha1(uniqid('',true)))); return substr($string, 0, $length); } echo token();

preferences:
59.93 ms | 402 KiB | 5 Q