<?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 => 'de',
  ),
  'this' => 
  array (
    0 => 'function.str-contains.php',
    1 => 'str_contains',
    2 => 'Pr&uuml;ft, ob eine Zeichenkette eine bestimmte Teilzeichenkette enth&auml;lt',
  ),
  'up' => 
  array (
    0 => 'ref.strings.php',
    1 => 'String-Funktionen',
  ),
  'prev' => 
  array (
    0 => 'function.sscanf.php',
    1 => 'sscanf',
  ),
  'next' => 
  array (
    0 => 'function.str-decrement.php',
    1 => 'str_decrement',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'de',
    'path' => 'reference/strings/functions/str-contains.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.str-contains" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">str_contains</h1>
  <p class="verinfo">(PHP 8)</p><p class="refpurpose"><span class="refname">str_contains</span> &mdash; <span class="dc-title">Prüft, ob eine Zeichenkette eine bestimmte Teilzeichenkette enthält</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.str-contains-description">
  <h3 class="title">Beschreibung</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>str_contains</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">
   Überprüft unter Berücksichtigung der Groß- und Kleinschreibung, ob
   <code class="parameter">needle</code> in <code class="parameter">haystack</code> enthalten
   ist.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.str-contains-parameters">
  <h3 class="title">Parameter-Liste</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">haystack</code></dt>
     <dd>
      <p class="para">
       Die zu durchsuchende Zeichenkette.
      </p>
     </dd>
    
    
     <dt><code class="parameter">needle</code></dt>
     <dd>
      <p class="para">
       Die Teilzeichenkette, nach der in <code class="parameter">haystack</code>
       gesucht werden soll.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.str-contains-returnvalues">
  <h3 class="title">Rückgabewerte</h3>
  <p class="para">
   Gibt <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> zurück, wenn <code class="parameter">needle</code> in
   <code class="parameter">haystack</code> enthalten ist, andernfalls <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.str-contains-examples">
  <h3 class="title">Beispiele</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Beispiel #1 Verwendung der leeren Zeichenkette <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_contains</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">"Die Prüfung auf die leere Zeichenkette ergibt immer true"</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>Das oben gezeigte Beispiel erzeugt folgende Ausgabe:</p></div>
    <div class="example-contents screen">
<div class="annotation-interactive examplescode"><pre class="examplescode">Die Prüfung auf die leere Zeichenkette ergibt immer true</pre>
</div>
    </div>
   </div>

   <div class="example" id="example-2">
    <p><strong>Beispiel #2 Beispiel für die Berücksichtigung von Groß- und Kleinschreibung</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_contains</span><span style="color: #007700">(</span><span style="color: #0000BB">$string</span><span style="color: #007700">, </span><span style="color: #DD0000">'lazy'</span><span style="color: #007700">)) {<br />    echo </span><span style="color: #DD0000">"Die Zeichenkette 'lazy' wurde in der Zeichenkette gefunden\n"</span><span style="color: #007700">;<br />}<br /><br />if (</span><span style="color: #0000BB">str_contains</span><span style="color: #007700">(</span><span style="color: #0000BB">$string</span><span style="color: #007700">, </span><span style="color: #DD0000">'Lazy'</span><span style="color: #007700">)) {<br />    echo </span><span style="color: #DD0000">'Die Zeichenkette "Lazy" wurde in der Zeichenkette gefunden'</span><span style="color: #007700">;<br />} else {<br />    echo </span><span style="color: #DD0000">'"Lazy" wurde nicht gefunden, weil die Groß- und Kleinschreibung nicht übereinstimmt'</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>Das oben gezeigte Beispiel erzeugt folgende Ausgabe:</p></div>
    <div class="example-contents screen">
<div class="annotation-interactive examplescode"><pre class="examplescode">Die Zeichenkette &#039;lazy&#039; wurde in der Zeichenkette gefunden
&quot;Lazy&quot; wurde nicht gefunden, weil die Groß- und Kleinschreibung nicht übereinstimmt</pre>
</div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.str-contains-notes">
  <h3 class="title">Anmerkungen</h3>
  <blockquote class="note"><p><strong class="note">Hinweis</strong>: <span class="simpara">Diese Funktion ist
binärsicher.</span></p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.str-contains-seealso">
  <h3 class="title">Siehe auch</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.str-ends-with.php" class="function" rel="rdfs-seeAlso">str_ends_with()</a> - Pr&uuml;ft, ob eine Zeichenkette mit einer bestimmten Teilzeichenkette endet</span></li>
    <li><span class="function"><a href="function.str-starts-with.php" class="function" rel="rdfs-seeAlso">str_starts_with()</a> - Pr&uuml;ft, ob eine Zeichenkette mit einer bestimmten Teilzeichenkette beginnt</span></li>
    <li><span class="function"><a href="function.stripos.php" class="function" rel="rdfs-seeAlso">stripos()</a> - Findet das erste Vorkommen eines Teilstrings in einem String, unabh&auml;ngig
   von Gro&szlig;- und Kleinschreibung</span></li>
    <li><span class="function"><a href="function.strrpos.php" class="function" rel="rdfs-seeAlso">strrpos()</a> - Findet die Position des letzten Vorkommens eines Teilstrings innerhalb
   einer Zeichenkette</span></li>
    <li><span class="function"><a href="function.strripos.php" class="function" rel="rdfs-seeAlso">strripos()</a> - Findet das letzte Vorkommen der gesuchten Zeichenkette in einem String,
   unabh&auml;ngig von Gro&szlig;- und Kleinschreibung</span></li>
    <li><span class="function"><a href="function.strstr.php" class="function" rel="rdfs-seeAlso">strstr()</a> - Findet das erste Vorkommen eines Strings</span></li>
    <li><span class="function"><a href="function.strpbrk.php" class="function" rel="rdfs-seeAlso">strpbrk()</a> - Durchsucht einen String nach einem Zeichen aus einer Gruppe von Zeichen</span></li>
    <li><span class="function"><a href="function.substr.php" class="function" rel="rdfs-seeAlso">substr()</a> - Liefert einen Teil eines Strings</span></li>
    <li><span class="function"><a href="function.preg-match.php" class="function" rel="rdfs-seeAlso">preg_match()</a> - F&uuml;hrt eine Suche mit einem regul&auml;ren Ausdruck durch</span></li>
   </ul>
  </p>
 </div>


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