mt_srand() function in PHP

The mt_srand() function seeds the Mersenne Twister random number generator.

Note − Random number generator is seeded automatically after the release of PHP 4.2.0. This function is not needed now.

Syntax

mt_srand(seed)

Parameters

  • seed − The seed value

Return

The mt_srand() function Returns nothing.

Example

<?php
   mt_srand(mktime());
   echo(mt_rand());
?>

Output

1320295657
Updated on: 2026-03-11T22:50:43+05:30

110 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements