<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.gmp.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'zh',
  ),
  'this' => 
  array (
    0 => 'function.gmp-init.php',
    1 => 'gmp_init',
    2 => 'Create GMP number',
  ),
  'up' => 
  array (
    0 => 'ref.gmp.php',
    1 => 'GMP 函数',
  ),
  'prev' => 
  array (
    0 => 'function.gmp-import.php',
    1 => 'gmp_import',
  ),
  'next' => 
  array (
    0 => 'function.gmp-intval.php',
    1 => 'gmp_intval',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/gmp/functions/gmp-init.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.gmp-init" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">gmp_init</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.0.4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">gmp_init</span> &mdash; <span class="dc-title">Create GMP number</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.gmp-init-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>gmp_init</strong></span>(<span class="methodparam"><span class="type"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span>|<span class="type"><a href="language.types.string.php" class="type string">string</a></span></span> <code class="parameter">$num</code></span>, <span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$base</code><span class="initializer"> = 0</span></span>): <span class="type"><a href="class.gmp.php" class="type GMP">GMP</a></span></div>

  <p class="para rdfs-comment">
   Creates a GMP number from an integer or string. 
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.gmp-init-parameters">
  <h3 class="title">参数</h3>
  <dl>
   
    <dt><code class="parameter">num</code></dt>
    <dd>
     <span class="simpara">
      An integer or a string. The string representation can be decimal,
      hexadecimal, octal, or binary.
     </span>
    </dd>
   
   
    <dt><code class="parameter">base</code></dt>
    <dd>
     <span class="simpara">
      The base to use for converting a <span class="type"><a href="language.types.string.php" class="type string">string</a></span> representation.
     </span>
     <span class="simpara">
      An explicit base can be between <code class="literal">2</code> and <code class="literal">62</code>.
      For bases up to <code class="literal">36</code>, case is ignored;
      upper-case and lower-case letters have the same value.
      For bases <code class="literal">37</code> to <code class="literal">62</code>,
      upper-case letter represent the values <code class="literal">10</code> to
      <code class="literal">35</code> and lower-case letter represent the values
      <code class="literal">36</code> to <code class="literal">61</code>.
     </span>
     <span class="simpara">
      If <code class="parameter">base</code> is <code class="literal">0</code> then the actual
      base is determined from the leading characters of <code class="parameter">num</code>.
      If the first two characters are <code class="literal">0x</code> or <code class="literal">0X</code>,
      the string is interpreted as a hexadecimal integer.
      If the first two characters are <code class="literal">0b</code> or <code class="literal">0B</code>,
      the string is interpreted as a binary integer.
      If the first two characters are <code class="literal">0o</code> or <code class="literal">0o</code>,
      the string is interpreted as an octal integer.
      Moreover, if the first character is <code class="literal">0</code> the string
      is also interpreted as an octal integer.
      In all other cases, the string is interpreted as a decimal integer.
     </span>
    </dd>
   
  </dl>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.gmp-init-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   <span class="classname"><a href="class.gmp.php" class="classname">GMP</a></span> 对象。
  </p>
 </div>


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

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.1.0</td>
      <td>
       Support for explicit octal prefixes <code class="literal">0o</code> and
       <code class="literal">0o</code> has been added for <code class="parameter">num</code> strings.
       Interpretation of such prefixes when <code class="parameter">base</code> is
       <code class="literal">0</code> has also been added.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.gmp-init-examples">
  <h3 class="title">示例</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>示例 #1 Creating GMP number</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$a </span><span style="color: #007700">= </span><span style="color: #0000BB">gmp_init</span><span style="color: #007700">(</span><span style="color: #0000BB">123456</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$b </span><span style="color: #007700">= </span><span style="color: #0000BB">gmp_init</span><span style="color: #007700">(</span><span style="color: #DD0000">"0xFFFFDEBACDFEDF7200"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.gmp-init-notes">
  <h3 class="title">注释</h3>
  <blockquote class="note"><p><strong class="note">注意</strong>: 
   <p class="para">
    It is not necessary to call this function in order to use integers or
    strings in place of GMP numbers in GMP functions (such as with
    <span class="function"><a href="function.gmp-add.php" class="function">gmp_add()</a></span>). Function arguments are automatically
    converted to GMP numbers, if such conversion is possible and needed, using
    the same rules as <span class="function"><strong>gmp_init()</strong></span>.
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.gmp-init-seealso">
  <h3 class="title">参见</h3>
  <ul class="simplelist">
   <li><span class="methodname"><a href="gmp.construct.php" class="methodname" rel="rdfs-seeAlso">GMP::__construct()</a> - Create GMP number</span></li>
  </ul>
 </div>

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