Tuesday, June 29, 2010

Difference between rand and mt_rand

We use rand() function to randomly generate a number.Now php has come up with another more powerful function named mt_rand. it is 10 times faster than the rand function. In php 5.2.1, Mersenne Twister algorithm uses a new seeding algorithm developed by Richard Wagner. Now identical seeds will not produce same results. mt_rand has the following defination:
mt_rand([int min], [int max]);
if we omit those values, it will product from 0 to mt_getrandmax() values. If we want to show a random number from 5 to 15 inclusive, then we need to write it like the following:
mt_rand(5,15);

See the book OpenCart 1.4 Template Design Cookbook.
See the book Joomla Mobile Development Beginners Guide




List of my works:

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide

No comments: