<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.splfileobject.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'es',
  ),
  'this' => 
  array (
    0 => 'splfileobject.fwrite.php',
    1 => 'SplFileObject::fwrite',
    2 => 'Escribe en el fichero',
  ),
  'up' => 
  array (
    0 => 'class.splfileobject.php',
    1 => 'SplFileObject',
  ),
  'prev' => 
  array (
    0 => 'splfileobject.ftruncate.php',
    1 => 'SplFileObject::ftruncate',
  ),
  'next' => 
  array (
    0 => 'splfileobject.getchildren.php',
    1 => 'SplFileObject::getChildren',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'es',
    'path' => 'reference/spl/splfileobject/fwrite.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="splfileobject.fwrite" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">SplFileObject::fwrite</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.1.0, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">SplFileObject::fwrite</span> &mdash; <span class="dc-title">Escribe en el fichero</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-splfileobject.fwrite-description">
  <h3 class="title">Descripción</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>SplFileObject::fwrite</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$data</code></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">$length</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>): <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.singleton.php" class="type false">false</a></span></span></div>

  <p class="para rdfs-comment">
   Escribe el contenido del argumento <code class="parameter">data</code>
   en el fichero.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-splfileobject.fwrite-parameters">
  <h3 class="title">Parámetros</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">data</code></dt>
     <dd>
      <p class="para">
       El <span class="type"><a href="language.types.string.php" class="type string">string</a></span> a escribir en el fichero.
      </p>
     </dd>
    
    
     <dt><code class="parameter">length</code></dt>
     <dd>
      <p class="para">
       Si el argumento <code class="parameter">length</code> es de tipo <span class="type"><a href="language.types.integer.php" class="type int">int</a></span>,
       la escritura se detendrá después de escribir <code class="parameter">length</code>
       bytes o bien cuando se alcance el final de <code class="parameter">data</code>; según
       lo que ocurra primero.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-splfileobject.fwrite-returnvalues">
  <h3 class="title">Valores devueltos</h3>
  <p class="para">
   Devuelve el número de bytes escritos, o <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> si ocurre un error.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-splfileobject.fwrite-changelog">
  <h3 class="title">Historial de cambios</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Versión</th>
      <th>Descripción</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.5.0</td>
      <td>
       <code class="parameter">length</code> ahora acepta <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong>.
      </td>
     </tr>

     <tr>
      <td>7.4.0</td>
      <td>
       Esta función devuelve ahora <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> en lugar de cero en caso de fallo.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-splfileobject.fwrite-examples">
  <h3 class="title">Ejemplos</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Ejemplo #1 Ejemplo con <span class="methodname"><strong>SplFileObject::fwrite()</strong></span></strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$file </span><span style="color: #007700">= new </span><span style="color: #0000BB">SplFileObject</span><span style="color: #007700">(</span><span style="color: #DD0000">"fwrite.txt"</span><span style="color: #007700">, </span><span style="color: #DD0000">"w"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$written </span><span style="color: #007700">= </span><span style="color: #0000BB">$file</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">fwrite</span><span style="color: #007700">(</span><span style="color: #DD0000">"12345"</span><span style="color: #007700">);<br />echo </span><span style="color: #DD0000">"</span><span style="color: #0000BB">$written</span><span style="color: #DD0000"> bytes han sido escritos en el fichero"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>Resultado del ejemplo anterior es similar a:</p></div>
    <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">5 bytes han sido escritos en el fichero</pre>
</div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-splfileobject.fwrite-seealso">
  <h3 class="title">Ver también</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.fwrite.php" class="function" rel="rdfs-seeAlso">fwrite()</a> - Escribe en un fichero en modo binario</span></li>
   </ul>
  </p>
 </div>


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