You need to generate a random number in your PHP script. What function would you use and why?

  • rand()
  • ceil()
  • floor()
  • round()
To generate a random number in PHP, you can use the rand() function. The rand() function generates a pseudo-random number within a specified range or, if no range is given, between 0 and the maximum random value supported by the system. This function is useful when you need to generate random numbers for various purposes, such as generating random IDs or selecting random elements from an array. Learn more: https://www.php.net/manual/en/function.rand.php
Add your answer
Loading...

Leave a comment

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