<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.ffi.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'uk',
  ),
  'this' => 
  array (
    0 => 'ffi.cast.php',
    1 => 'FFI::cast',
    2 => 'Performs a C type cast',
  ),
  'up' => 
  array (
    0 => 'class.ffi.php',
    1 => 'FFI',
  ),
  'prev' => 
  array (
    0 => 'ffi.arraytype.php',
    1 => 'FFI::arrayType',
  ),
  'next' => 
  array (
    0 => 'ffi.cdef.php',
    1 => 'FFI::cdef',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/ffi/ffi/cast.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="ffi.cast" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">FFI::cast</h1>
  <p class="verinfo">(PHP 7 &gt;= 7.4.0, PHP 8)</p><p class="refpurpose"><span class="refname">FFI::cast</span> &mdash; <span class="dc-title">Performs a C type cast</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-ffi.cast-description">
  <h3 class="title">Опис</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>FFI::cast</strong></span>(<span class="methodparam"><span class="type"><span class="type"><a href="class.ffi-ctype.php" class="type FFI\CType">FFI\CType</a></span>|<span class="type"><a href="language.types.string.php" class="type string">string</a></span></span> <code class="parameter">$type</code></span>, <span class="methodparam"><span class="type"><span class="type"><a href="class.ffi-cdata.php" class="type FFI\CData">FFI\CData</a></span>|<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>|<span class="type"><a href="language.types.float.php" class="type float">float</a></span>|<span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span>|<span class="type"><a href="language.types.null.php" class="type null">null</a></span></span> <code class="parameter reference">&$ptr</code></span>): <span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="class.ffi-cdata.php" class="type FFI\CData">FFI\CData</a></span></span></div>

  <p class="para rdfs-comment">
   <span class="methodname"><strong>FFI::cast()</strong></span> creates a new <span class="classname"><a href="class.ffi-cdata.php" class="classname">FFI\CData</a></span>
   object, that references the same C data structure, but is associated with a different type.
   The resulting object does not own the C data, and the source <code class="parameter">ptr</code>
   must survive the result. The C type may be specified as a <span class="type"><a href="language.types.string.php" class="type string">string</a></span> with any
   valid C type declaration or as <span class="classname"><a href="class.ffi-ctype.php" class="classname">FFI\CType</a></span> object, created before.
   Any type declared for the instance is allowed.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-ffi.cast-parameters">
  <h3 class="title">Параметри</h3>
  <dl>
   
    <dt><code class="parameter">type</code></dt>
    <dd>
     <p class="para">
      A valid C declaration as <span class="type"><a href="language.types.string.php" class="type string">string</a></span>, or an instance of <span class="classname"><a href="class.ffi-ctype.php" class="classname">FFI\CType</a></span>
      which has already been created.
     </p>
    </dd>
   
   
    <dt><code class="parameter">ptr</code></dt>
    <dd>
     <p class="para">
      The handle of the pointer to a C data structure.
     </p>
    </dd>
   
  </dl>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-ffi.cast-returnvalues">
  <h3 class="title">Значення, що повертаються</h3>
  <p class="para">
   Returns the freshly created <span class="classname"><a href="class.ffi-cdata.php" class="classname">FFI\CData</a></span> object.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-ffi.cast-changelog">
  <h3 class="title">Журнал змін</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>Версія</th>
       <th>Опис</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>8.3.0</td>
       <td>
        Calling <span class="methodname"><strong>FFI::cast()</strong></span> statically is now deprecated.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


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