Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8134385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T10:00:19+00:00 2026-06-06T10:00:19+00:00

Let we explain what I mean. Some time ago, while writing a program in

  • 0

Let we explain what I mean.

Some time ago, while writing a program in c#, I’ve made following mistake:

int Randomize()
{
    Random r=new Random();
    return  r.Next(0,10);
}

in c#, this is a mistake, because, called several times in a row, this function will return the same value. This is because Random constructor uses time seed, and the time difference between calls was too low (took me an hour to find that one 🙂 ).

Now I’m using rand(...) in php, and I need for the output to always be different, even if 2 scripts are executed at the same time.

Do I have to do something to get this result, or is it designed to work this way?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T10:00:21+00:00Added an answer on June 6, 2026 at 10:00 am

    the rand() and also mt_rand() calls srand() and mt_srand() to produce always random results.
    But here’s an interesting post on php.net:

    Note that the automatic seeding seems to be done with the current
    number of seconds which means you can get the same results for several
    runs on a fast server. Either call srand() yourself with a more
    frequently changing seed or use mt_rand() which doesn’t appear to
    suffer from the problem.

    So, just call srand more frequently or mt_rand.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let me explain what I mean : Let's say we have a menu with
Let me explain: I need to sort a list in ascending order, while results
Is this possible? Let me explain what I mean. I have migrated from svn
Let me explain what I mean with that question: Lets say I have to
Let me explain what I mean in my title. Let's say, that for example
I am looking for some sort of dynamic testing tool. Let me explain what
Okay, let's see if I can explain what I mean, here's an image to
Let me explain what I mean when I say fluent audio stream. I have
Let me explain what I mean when I say that I want to rotate
The title may be long, let me explain what I mean. I won't give

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.