<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.random.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'de',
  ),
  'this' => 
  array (
    0 => 'function.srand.php',
    1 => 'srand',
    2 => 'Legt den Anfangswert f&uuml;r den Zufallsgenerator fest',
  ),
  'up' => 
  array (
    0 => 'ref.random.php',
    1 => 'Random Funktionen',
  ),
  'prev' => 
  array (
    0 => 'function.random-int.php',
    1 => 'random_int',
  ),
  'next' => 
  array (
    0 => 'class.random-randomizer.php',
    1 => 'Random\\Randomizer',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'de',
    'path' => 'reference/random/functions/srand.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.srand" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">srand</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">srand</span> &mdash; <span class="dc-title">Legt den Anfangswert für den Zufallsgenerator fest</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.srand-description">
  <h3 class="title">Beschreibung</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>srand</strong></span>(<span class="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.integer.php" class="type int">int</a></span></span> <code class="parameter">$seed</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>, <span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$mode</code><span class="initializer"> = <strong><code><a href="random.constants.php#constant.mt-rand-mt19937">MT_RAND_MT19937</a></code></strong></span></span>): <span class="type"><a href="language.types.void.php" class="type void">void</a></span></div>

  <p class="para rdfs-comment">
   Setzt den Anfangswert für den Zufallsgenerator auf
   <code class="parameter">seed</code> oder auf einen zufälligen Wert, falls kein
   <code class="parameter">seed</code> angegeben wurde.
  </p>

  <blockquote class="note"><p><strong class="note">Hinweis</strong>: <span class="simpara">Es besteht keine
Notwendigkeit, den Zufallsgenerator für Zahlen mit
<span class="function"><strong>srand()</strong></span> oder <span class="function"><a href="function.mt-srand.php" class="function">mt_srand()</a></span> zu füttern, das
geschieht automatisch.</span></p></blockquote>
  <div class="caution"><strong class="caution">Achtung</strong>
 <p class="para">
  Da die Mt19937- (&quot;Mersenne Twister&quot;) Engine nur einen einzigen 32-Bit-Integer als Seed akzeptiert,
  ist die Anzahl der möglichen Zufallsfolgen trotz der riesigen Periode von 2<sup class="superscript">19937</sup>-1
  auf nur 2<sup class="superscript">32</sup> (d. h. 4.294.967.296) begrenzt.
 </p>
 <p class="para">
  Wenn man sich auf implizites oder explizites zufälliges Seeding verlässt, treten
  Duplikate viel früher auf. Nach dem Geburtstagsproblem werden doppelte Seeds mit einer
  Wahrscheinlichkeit von 50% nach weniger als 80.000 zufällig erzeugten Seeds
  erwartet. Nach etwa 30.000 zufällig erzeugten Seeds tritt ein doppeltes Seed mit
  einer Wahrscheinlichkeit von 10% auf.
 </p>
 <p class="para">
  Daher ist Mt19937 nicht für Anwendungen geeignet, bei denen doppelte Sequenzen nur mit vernachlässigbarer
  Wahrscheinlichkeit auftreten dürfen. Wenn reproduzierbares Seeding erforderlich ist,
  unterstützen sowohl <span class="classname"><a href="class.random-engine-xoshiro256starstar.php" class="classname">Random\Engine\Xoshiro256StarStar</a></span> als auch
  <span class="classname"><a href="class.random-engine-pcgoneseq128xslrr64.php" class="classname">Random\Engine\PcgOneseq128XslRr64</a></span> wesentlich größere Seeds, bei denen eine
  zufällige Kollision unwahrscheinlich ist. Wenn keine Reproduzierbarkeit erforderlich ist, bietet die
  Engine <span class="classname"><a href="class.random-engine-secure.php" class="classname">Random\Engine\Secure</a></span> eine kryptografisch sichere Zufallsverteilung.
 </p>
</div>
  <blockquote class="note"><p><strong class="note">Hinweis</strong>: 
   <span class="simpara">
    Von PHP 7.1.0 an ist <span class="function"><strong>srand()</strong></span> ein Alias von
    <span class="function"><a href="function.mt-srand.php" class="function">mt_srand()</a></span>.
   </span>
  </p></blockquote>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.srand-parameters">
  <h3 class="title">Parameter-Liste</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">seed</code></dt>
     <dd>
      <p class="para">
       Füllt den Zustand mit Werten, die mit einem linearen Kongruenzgenerator
       erzeugt wurden, der mit <code class="parameter">seed</code>,
       interpretiert als vorzeichenlose 32-Bit-Ganzzahl, initialisiert wurde.
      </p>
      <p class="para">
       Wenn <code class="parameter">seed</code> weggelassen wird oder <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong> ist, wird
       eine zufällige vorzeichenlose 32-Bit-Ganzzahl verwendet.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.srand-returnvalues">
  <h3 class="title">Rückgabewerte</h3>
  <p class="para">
   Es wird kein Wert zurückgegeben.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.srand-changelog">
  <h3 class="title">Changelog</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>Version</th>
       <th>Beschreibung</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>8.3.0</td>
       <td>
        <code class="parameter">seed</code> kann nun <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong> sein.
       </td>
      </tr>

      <tr>
       <td>7.1.0</td>
       <td>
        <span class="function"><strong>srand()</strong></span>
        <a href="migration71.incompatible.php#migration71.incompatible.rand-srand-aliases" class="link">ist nun</a>
        ein Alias von <span class="function"><a href="function.mt-srand.php" class="function">mt_srand()</a></span>.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.srand-seealso">
  <h3 class="title">Siehe auch</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.rand.php" class="function" rel="rdfs-seeAlso">rand()</a> - Erzeugt eine zuf&auml;llige Zahl</span></li>
    <li><span class="function"><a href="function.getrandmax.php" class="function" rel="rdfs-seeAlso">getrandmax()</a> - Liefert die gr&ouml;&szlig;tm&ouml;gliche Zufallszahl</span></li>
    <li><span class="function"><a href="function.mt-srand.php" class="function" rel="rdfs-seeAlso">mt_srand()</a> - Initialisiert den Mersenne-Twister-Zufallszahlengenerator</span></li>
   </ul>
  </p>
 </div>


</div><?php manual_footer($setup); ?>