PHP:
  1. $guid = md5(uniqid(rand(), true));

  • md5 sanitizes the ID and limits it to 32 characters.
  • uniqid generates a random ID based on your server's time, etc.
    • rand() is prefixed onto the ID - thus enhancing the ID's uniqueness.
    • true tells uniqid() to make use of "more entropy" - again enhancing the ID's uniqueness.
Share
Share →

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>