<?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 => 'zh',
  ),
  'this' => 
  array (
    0 => 'function.lcg-value.php',
    1 => 'lcg_value',
    2 => '组合线性同余发生器',
  ),
  'up' => 
  array (
    0 => 'ref.random.php',
    1 => 'Random 函数',
  ),
  'prev' => 
  array (
    0 => 'function.getrandmax.php',
    1 => 'getrandmax',
  ),
  'next' => 
  array (
    0 => 'function.mt-getrandmax.php',
    1 => 'mt_getrandmax',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'zh',
    'path' => 'reference/random/functions/lcg-value.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.lcg-value" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">lcg_value</h1>
   <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">lcg_value</span> &mdash; <span class="dc-title">组合线性同余发生器</span></p>

 </div>

 <div id="function.lcg-value-refsynopsisdiv">
  <div class="warning"><strong class="warning">警告</strong><p class="simpara">此函数自 PHP 8.4.0
起<em>弃用</em>。强烈建议不要应用此函数。</p></div>
 </div>

 <div class="refsect1 description" id="refsect1-function.lcg-value-description">
  <h3 class="title">说明</h3>
   <div class="methodsynopsis dc-description">
    <span class="attribute"><a href="class.deprecated.php">#[\Deprecated]</a> </span><br>
    <span class="methodname"><strong>lcg_value</strong></span>(): <span class="type"><a href="language.types.float.php" class="type float">float</a></span></div>

  <p class="para rdfs-comment">
   <span class="function"><strong>lcg_value()</strong></span> 返回范围为
   (0, 1) 的一个伪随机数。本函数组合了周期为
   2^31 - 85 和 2^31 - 249 的两个同余发生器。本函数的周期等于这两个素数的乘积。
  </p>
  <div class="caution"><strong class="caution">警告</strong>
 <p class="para">
  本函数并不会生成安全加密的值，并且<em>不可</em>用于加密或者要求返回值不可猜测的目的。
 </p>
 <p class="para">
  如果需要加密安全随机，则可以将 <span class="classname"><a href="class.random-engine-secure.php" class="classname">Random\Engine\Secure</a></span> 引擎用于
  <span class="classname"><a href="class.random-randomizer.php" class="classname">Random\Randomizer</a></span>。对于简单的用例，<span class="function"><a href="function.random-int.php" class="function">random_int()</a></span>
  和 <span class="function"><a href="function.random-bytes.php" class="function">random_bytes()</a></span> 函数提供了操作系统的 <abbr title="Cryptographically Secure PseudoRandom Number Generator">CSPRNG</abbr> 支持的方便且安全的 <abbr title="Application Programming Interface">API</abbr>。
 </p>
</div>
  <div class="caution"><strong class="caution">警告</strong>
   <p class="para">
    Scaling the return value to a different interval using multiplication
    or addition (a so-called affine transformation) might result in a bias
    in the resulting value as floats are not equally dense across the number
    line. As not all values can be exactly represented by a float, the
    result of the affine transformation might also result in values outside
    of the requested interval.
   </p>
   <p class="para">
    使用 <span class="methodname"><a href="random-randomizer.getfloat.php" class="methodname">Random\Randomizer::getFloat()</a></span> 在任意间隔内生成随机浮点数。使用
    <span class="methodname"><a href="random-randomizer.getint.php" class="methodname">Random\Randomizer::getInt()</a></span> 在任意间隔内生成随机整数。
   </p>
  </div>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.lcg-value-parameters">
  <h3 class="title">参数</h3>
  <p class="para">此函数没有参数。</p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.lcg-value-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   介于 0.0 和 1.0（含）之间的伪随机浮点值。
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.lcg-value-changelog">
  <h3 class="title">更新日志</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>版本</th>
      <th>说明</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.4.0</td>
      <td>
       此函数已被弃用。
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 seealso" id="refsect1-function.lcg-value-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="methodname"><a href="random-randomizer.getfloat.php" class="methodname" rel="rdfs-seeAlso">Random\Randomizer::getFloat()</a> - Get a uniformly selected float</span></li>
    <li><span class="methodname"><a href="random-randomizer.getint.php" class="methodname" rel="rdfs-seeAlso">Random\Randomizer::getInt()</a> - Get a uniformly selected integer</span></li>
    <li><span class="function"><a href="function.random-int.php" class="function" rel="rdfs-seeAlso">random_int()</a> - 获取生成加密安全、均匀分布的整数</span></li>
   </ul>
  </p>
 </div>

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