1

I try to make function that generate random id using $_SERVER["REMOTE_PORT"] and microtime() , so i ask if if $_SERVER["REMOTE_PORT"] Can be repeated for more than one device at the same time

bnabriss
  • 89
  • 6

1 Answers1

0

The repeating can occurs if some cases like:

  • If you run your code in cloud apps, it may that two requests has same port in two servers in same time, since all request should has it's unique port at the same time.
  • If your server is High-speed, it may that the port server the first request and finish it, and then server the second request and finish it in the same instance time.

In general it's quite rarely to have this issue, you also can use microtime(false) to get more decimal points for microtime functions, Also I recommend to view mt_rand function to generate fast random numbers.

bnabriss
  • 89
  • 6