- substr: documentation ( source)
- uniqid: documentation ( source)
- sha1: documentation ( source)
- str_replace: documentation ( source)
- base64_encode: documentation ( source)
<?php
function token($length = 30) {
$string = str_replace(['=','+','/'], '', base64_encode(sha1(uniqid('',true))));
return substr($string, 0, $length);
}
echo token();