private function randomToken($length = 32)
    {
        if (!isset($length) || intval($length) <= 8) {
            $length = 32;
        }
        if (function_exists('random_bytes')) {
            return random_bytes($length);
        }
        if (function_exists('mcrypt_create_iv')) {
            return mcrypt_create_iv($length, MCRYPT_DEV_URANDOM);
        }
        if (function_exists('openssl_random_pseudo_bytes')) {
            return openssl_random_pseudo_bytes($length);
        }

        return @crypt(uniqid());
    }
private function randomToken($length = 32)
    {
        if (!isset($length) || intval($length) <= 8) {
            $length = 32;
        }
        if (function_exists('random_bytes')) {
            return random_bytes($length);
        }
        if (function_exists('mcrypt_create_iv')) {
            return mcrypt_create_iv($length, MCRYPT_DEV_URANDOM);
        }
        if (function_exists('openssl_random_pseudo_bytes')) {
            return openssl_random_pseudo_bytes($length);
        }

        return @crypt(uniqid());
    }
private function randomToken ( $ length = 32 ) { if ( ! isset ( $ length ) || intval ( $ length ) <= 8 ) { $ length = 32 ; } if ( function_exists ( 'random_bytes' ) ) { return random_bytes ( $ length ) ; } if ( function_exists ( 'mcrypt_create_iv' ) ) { return mcrypt_create_iv ( $ length , MCRYPT_DEV_URANDOM ) ; } if ( function_exists ( 'openssl_random_pseudo_bytes' ) ) { return openssl_random_pseudo_bytes ( $ length ) ; } return @ crypt ( uniqid ( ) ) ; }
Return a random token.

@param int $length The length of the random string that should be returned in bytes

@return string
Return a random token .