PHP Classes

This looks a bit useless

Recommend this page to a friend!

      Synchronizer Token Pattern  >  All threads  >  This looks a bit useless  >  (Un) Subscribe thread alerts  
Subject:This looks a bit useless
Summary:Too much code
Messages:1
Author:Eric Wagener
Date:2014-05-27 14:51:36
 

  1. This looks a bit useless   Reply   Report abuse  
Picture of Eric Wagener Eric Wagener - 2014-05-27 14:51:37
This can be done in a few lines:

<?php
function getToken($chars = 20) {
$letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789*/+-=@#$%&!?;:._\|{[()]}";
return substr(str_shuffle($letters), 0, $chars);
}

BTW: When the function in your class is called repeatedly, the $this->results will get bigger and bigger.