Adrian World Design
  • Services
    • Website Consulting
    • Startup Consulting
    • Zend Development
  • Portfolio
    • My Framework
  • Knowledge
    • Web Standards
    • PHP bare-bones
    • Zend Framework
    • Zend Framework 2
    • Git - Github
    • Search Engine Optimization
    • Web Hosting
    • Linux
    • Microsoft Windows
    • Web Browsers
    • Mobile Devices
  • About
    • Business
    • Professionally
    • Personally
  • Contact
    • Contact Form
    • Phone
    • Email
    • Messaging

Knowledge Base Overview

Create a unique ID

Knowledge ⇒ Zend Framework ⇒ OAQ - Occasionally asked questions ⇒ Create a unique ID
Tweet
Share on Tumblr

Created: Mar 27, 2012, 11:21:11 AM CSTLast updated: Oct 31, 2012, 7:26:35 AM CST

Ever since I wrote an article about how to get a unique ID in Apache I have traffic from Google with questions about how to get or create a unique ID in PHP or the Zend Framework and even Wordpress, Drupal or Joomla.

If you need a unique ID in your web application written with PHP, which includes my specialty the Zend Framework, or other frameworks like CodeIgniter, Drupal, Yii or CMS systems like Wordpress and Joomla, then you have several choices.

How unique

First we need to find an answer to the question about how unique this ID has to be. I guess it all depends on the requirement for this ID.

You may need a unique ID for a log file to identify each single web request, i.e. you like to see all log events resulting from the same request. If you have Apache you are lucky because your Apache web server can provide you with an ID for each single web request. How you can use this can be found in my other document I mentioned: Unique ID per request.

If you need a unique ID to identify more than just one single web request you could still use this unique ID from the Apache module. Catch it with the first request and keep using it.

PHP function: uniqid

If that previous method does not work for you because you maybe use Microsoft's IIS you have another option which is a PHP function named uniqid. See the PHP documentation uniqid for how to use it.

Because we have this PHP function there is in fact no need to handle or find it in your Zend Framework. And actually WordPress, Joomla, Drupal, Cake or any other framework.

Apache's module way should also work for other web languages like Perl, ASP, Ruby or whatever language you are using.

blog comments powered by Disqus
Prev
Next

Powered by FeedBurner Load our "Knowledge Base" feed in your RSS feeder

Follow us on Twitter
Follow us on Facebook
Follow us on LinkedIn
Follow us on Google+

All rights reserved, Adrian World Design ©2009–2021 Powered by Wejas Framework

Jump to Top