<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.random-engine-pcgoneseq128xslrr64.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'zh',
  ),
  'this' => 
  array (
    0 => 'random-engine-pcgoneseq128xslrr64.construct.php',
    1 => 'Random\\Engine\\PcgOneseq128XslRr64::__construct',
    2 => 'Constructs a new PCG Oneseq 128 XSL RR 64 engine',
  ),
  'up' => 
  array (
    0 => 'class.random-engine-pcgoneseq128xslrr64.php',
    1 => 'Random\\Engine\\PcgOneseq128XslRr64',
  ),
  'prev' => 
  array (
    0 => 'class.random-engine-pcgoneseq128xslrr64.php',
    1 => 'Random\\Engine\\PcgOneseq128XslRr64',
  ),
  'next' => 
  array (
    0 => 'random-engine-pcgoneseq128xslrr64.debuginfo.php',
    1 => 'Random\\Engine\\PcgOneseq128XslRr64::__debugInfo',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/random/random/engine/pcgoneseq128xslrr64/construct.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="random-engine-pcgoneseq128xslrr64.construct" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">Random\Engine\PcgOneseq128XslRr64::__construct</h1>
  <p class="verinfo">(PHP 8 &gt;= 8.2.0)</p><p class="refpurpose"><span class="refname">Random\Engine\PcgOneseq128XslRr64::__construct</span> &mdash; <span class="dc-title">Constructs a new PCG Oneseq 128 XSL RR 64 engine</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-random-engine-pcgoneseq128xslrr64.construct-description">
  <h3 class="title">说明</h3>
  <div class="constructorsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>Random\Engine\PcgOneseq128XslRr64::__construct</strong></span>(<span class="methodparam"><span class="type"><span class="type"><a href="language.types.string.php" class="type string">string</a></span>|<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>|<span class="type"><a href="language.types.null.php" class="type null">null</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>)</div>

  <p class="para rdfs-comment">

  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-random-engine-pcgoneseq128xslrr64.construct-parameters">
  <h3 class="title">参数</h3>
  <dl>
   
    <dt><code class="parameter">seed</code></dt>
    <dd>
     <p class="para">
      How the internal 128 bit (16 byte) state consisting of one unsigned 128 bit integer is
      seeded depends on the type used as the <code class="parameter">seed</code>.
      <table class="doctable informaltable">
       
        <thead>
         <tr>
          <th>Type</th>
          <th>说明</th>
         </tr>

        </thead>

        <tbody class="tbody">
         <tr>
          <td><span class="type"><a href="language.types.null.php" class="type null">null</a></span></td>
          <td>
           Fills the state with 16 random bytes generated using the <abbr title="Cryptographically Secure PseudoRandom Number Generator">CSPRNG</abbr>.
          </td>
         </tr>

         <tr>
          <td><span class="type"><a href="language.types.integer.php" class="type int">int</a></span></td>
          <td>
           Fills the state by setting the state to <code class="literal">0</code>, advancing the engine one step,
           adding the value of <code class="parameter">seed</code> interpreted as an unsigned 64 bit integer,
           and advancing the engine another step.
          </td>
         </tr>

         <tr>
          <td><span class="type"><a href="language.types.string.php" class="type string">string</a></span></td>
          <td>
           Fills the state by interpreting a 16 byte <span class="type"><a href="language.types.string.php" class="type string">string</a></span> as a little-endian unsigned
           128 bit integer.
          </td>
         </tr>

        </tbody>
       
      </table>

     </p>
    </dd>
   
  </dl>
 </div>


 

 <div class="refsect1 errors" id="refsect1-random-engine-pcgoneseq128xslrr64.construct-errors">
  <h3 class="title">错误／异常</h3>
  <ul class="itemizedlist">
   <li class="listitem">
    <span class="simpara">
     If the length of a <span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">seed</code> is
     not 16 bytes, a <span class="classname"><a href="class.valueerror.php" class="classname">ValueError</a></span> will be thrown.
    </span>
   </li>
  </ul>
 </div>


 <div class="refsect1 examples" id="refsect1-random-engine-pcgoneseq128xslrr64.construct-examples">
  <h3 class="title">示例</h3>
  <div class="example" id="example-1">
   <p><strong>示例 #1 <span class="function"><strong>Random\Engine\PcgOneseq128XslRr64::__construct()</strong></span> example</strong></p>
   <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">// Uses a random 128 Bit seed.<br /></span><span style="color: #0000BB">$e </span><span style="color: #007700">= new </span><span style="color: #0000BB">\Random\Engine\PcgOneseq128XslRr64</span><span style="color: #007700">();<br /><br /></span><span style="color: #0000BB">$r </span><span style="color: #007700">= new </span><span style="color: #0000BB">\Random\Randomizer</span><span style="color: #007700">(</span><span style="color: #0000BB">$e</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
   </div>

  </div>
  <div class="example" id="example-2">
   <p><strong>示例 #2 Deriving a seed from a <span class="type"><a href="language.types.string.php" class="type string">string</a></span></strong></p>
   <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$string </span><span style="color: #007700">= </span><span style="color: #DD0000">"My string seed"</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">// Hash the string with truncated SHA-256 using binary output<br />// to turn the $string into a 128 Bit seed. Using the same<br />// string will result in the same sequence of randomness.<br /></span><span style="color: #0000BB">$e </span><span style="color: #007700">= new </span><span style="color: #0000BB">\Random\Engine\PcgOneseq128XslRr64</span><span style="color: #007700">(<br />    </span><span style="color: #0000BB">substr</span><span style="color: #007700">(</span><span style="color: #0000BB">hash</span><span style="color: #007700">(</span><span style="color: #DD0000">'sha256'</span><span style="color: #007700">, </span><span style="color: #0000BB">$string</span><span style="color: #007700">, </span><span style="color: #0000BB">binary</span><span style="color: #007700">: </span><span style="color: #0000BB">true</span><span style="color: #007700">), </span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">16</span><span style="color: #007700">)<br />);<br /><br />echo </span><span style="color: #0000BB">bin2hex</span><span style="color: #007700">(</span><span style="color: #0000BB">$e</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">generate</span><span style="color: #007700">()), </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
   </div>

   <div class="example-contents"><p>以上示例会输出：</p></div>
   <div class="example-contents screen">
<div class="annotation-interactive examplescode"><pre class="examplescode">8333ef59315b16d8</pre>
</div>
   </div>
  </div>
 </div>



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