<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.strings.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'es',
  ),
  'this' => 
  array (
    0 => 'function.str-starts-with.php',
    1 => 'str_starts_with',
    2 => 'Determina si un string comienza con un substring dado',
  ),
  'up' => 
  array (
    0 => 'ref.strings.php',
    1 => 'Funciones de strings',
  ),
  'prev' => 
  array (
    0 => 'function.str-split.php',
    1 => 'str_split',
  ),
  'next' => 
  array (
    0 => 'function.str-word-count.php',
    1 => 'str_word_count',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'es',
    'path' => 'reference/strings/functions/str-starts-with.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.str-starts-with" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">str_starts_with</h1>
  <p class="verinfo">(PHP 8)</p><p class="refpurpose"><span class="refname">str_starts_with</span> &mdash; <span class="dc-title">Determina si un string comienza con un substring dado</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.str-starts-with-description">
  <h3 class="title">Descripción</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>str_starts_with</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$haystack</code></span>, <span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$needle</code></span>): <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>

  <p class="para rdfs-comment">
   Realiza una verificación sensible a mayúsculas y minúsculas que indica si
   <code class="parameter">haystack</code> (pajar) comienza con <code class="parameter">needle</code> (aguja).
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.str-starts-with-parameters">
  <h3 class="title">Parámetros</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">haystack</code></dt>
     <dd>
      <p class="para">
       El string en la que se realiza la búsqueda.
      </p>
     </dd>
    
    
     <dt><code class="parameter">needle</code></dt>
     <dd>
      <p class="para">
       El substring a buscar en <code class="parameter">haystack</code>.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.str-starts-with-returnvalues">
  <h3 class="title">Valores devueltos</h3>
  <p class="para">
   Devuelve <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> si <code class="parameter">haystack</code> comienza con
   <code class="parameter">needle</code>, de lo contrario <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.str-starts-with-examples">
  <h3 class="title">Ejemplos</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Ejemplo #1 Con un string vacío <code class="literal">&#039;&#039;</code></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: #007700">if (</span><span style="color: #0000BB">str_starts_with</span><span style="color: #007700">(</span><span style="color: #DD0000">'abc'</span><span style="color: #007700">, </span><span style="color: #DD0000">''</span><span style="color: #007700">)) {<br />    echo </span><span style="color: #DD0000">"Todas los strings comienzan con el string vacía"</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>El ejemplo anterior mostrará:</p></div>
    <div class="example-contents screen">
<div class="annotation-interactive examplescode"><pre class="examplescode">Todas los strings comienzan con el string vacía</pre>
</div>
    </div>
   </div>

   <div class="example" id="example-2">
    <p><strong>Ejemplo #2 Demostración de la sensibilidad a mayúsculas y minúsculas</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">'The lazy fox jumped over the fence'</span><span style="color: #007700">;<br /><br />if (</span><span style="color: #0000BB">str_starts_with</span><span style="color: #007700">(</span><span style="color: #0000BB">$string</span><span style="color: #007700">, </span><span style="color: #DD0000">'The'</span><span style="color: #007700">)) {<br />    echo </span><span style="color: #DD0000">"El string comienza con 'The'\n"</span><span style="color: #007700">;<br />}<br /><br />if (</span><span style="color: #0000BB">str_starts_with</span><span style="color: #007700">(</span><span style="color: #0000BB">$string</span><span style="color: #007700">, </span><span style="color: #DD0000">'the'</span><span style="color: #007700">)) {<br />    echo </span><span style="color: #DD0000">'El string comienza con "the"'</span><span style="color: #007700">;<br />} else {<br />    echo </span><span style="color: #DD0000">'"the" no fue encontrado porque las mayúsculas y minúsculas no coinciden'</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>El ejemplo anterior mostrará:</p></div>
    <div class="example-contents screen">
<div class="annotation-interactive examplescode"><pre class="examplescode">El string comienza con &#039;The&#039;
&quot;the&quot; no fue encontrado porque las mayúsculas y minúsculas no coinciden</pre>
</div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.str-starts-with-notes">
  <h3 class="title">Notas</h3>
  <blockquote class="note"><p><strong class="note">Nota</strong>: <span class="simpara">Esta función es
segura para sistemas binarios.</span></p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.str-starts-with-seealso">
  <h3 class="title">Ver también</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.str-contains.php" class="function" rel="rdfs-seeAlso">str_contains()</a> - Determina si una cadena contiene un substring dado</span></li>
    <li><span class="function"><a href="function.str-ends-with.php" class="function" rel="rdfs-seeAlso">str_ends_with()</a> - Determina si una cadena termina con un substring dado</span></li>
    <li><span class="function"><a href="function.stripos.php" class="function" rel="rdfs-seeAlso">stripos()</a> - Busca la posici&oacute;n de la primera ocurrencia en un string, sin distinguir may&uacute;sculas de min&uacute;sculas</span></li>
    <li><span class="function"><a href="function.strrpos.php" class="function" rel="rdfs-seeAlso">strrpos()</a> - Busca la posici&oacute;n de la &uacute;ltima ocurrencia de una subcadena en una cadena</span></li>
    <li><span class="function"><a href="function.strripos.php" class="function" rel="rdfs-seeAlso">strripos()</a> - Busca la posici&oacute;n de la &uacute;ltima ocurrencia de un string contenido en otro, de forma insensible a may&uacute;sculas y min&uacute;sculas</span></li>
    <li><span class="function"><a href="function.strstr.php" class="function" rel="rdfs-seeAlso">strstr()</a> - Encuentra la primera ocurrencia en un string</span></li>
    <li><span class="function"><a href="function.strpbrk.php" class="function" rel="rdfs-seeAlso">strpbrk()</a> - Busca un conjunto de caracteres en un string</span></li>
    <li><span class="function"><a href="function.substr.php" class="function" rel="rdfs-seeAlso">substr()</a> - Devuelve un segmento de string</span></li>
    <li><span class="function"><a href="function.preg-match.php" class="function" rel="rdfs-seeAlso">preg_match()</a> - Realiza una b&uacute;squeda de coincidencia con una expresi&oacute;n regular est&aacute;ndar</span></li>
   </ul>
  </p>
 </div>


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