

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
srand() function in PHP
<p>The mt_srand() function seeds the random number generator.</p><p><strong>Note</strong> − Random number generator is seeded automatically after the release of PHP 4.2.0. This function is not needed now.</p><h2>Syntax</h2><pre class="result notranslate">srand(seed)</pre><h2>Parameters</h2><ul class="list"><li><p><strong>seed</strong> − The seed value</p></li></ul><h2>Return</h2><p>The srand() function Returns nothing.</p><h2>Example</h2><p><a class="demo" href="http://tpcg.io/9pBE1U" rel="nofollow" target="_blank"> Live Demo</a></p><pre class="prettyprint notranslate"><?php srand(mktime()); echo(mt_rand()); ?></pre><h2>Output</h2><pre class="result notranslate">664617053</pre><h2>Example</h2><p>Let us see another example −</p><p><a class="demo" href="http://tpcg.io/pXqorF" rel="nofollow" target="_blank"> Live Demo</a></p><pre class="prettyprint notranslate"><?php srand(2); echo(rand(1, 5)); ?></pre><h2>Output</h2><pre class="result notranslate">4</pre>
- Related Questions & Answers
- PHP srand() Function
- rand() and srand() in C
- rand() and srand() in C/C++
- file_exists() function in PHP
- basename( ) function in PHP
- chgrp()function in PHP
- chmod() function in PHP
- chown() function in PHP
- clearstatcache() function in PHP
- copy() function in PHP
- delete() function in PHP
- dirname()function in PHP
- disk_free_space() function in PHP
- disk_total_space() function in PHP
- diskfreespace() function in PHP
Advertisements