<?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 => 'ja',
  ),
  'this' => 
  array (
    0 => 'function.stripos.php',
    1 => 'stripos',
    2 => '大文字小文字を区別せずに文字列が最初に現れる位置を探す',
  ),
  'up' => 
  array (
    0 => 'ref.strings.php',
    1 => 'String 関数',
  ),
  'prev' => 
  array (
    0 => 'function.stripcslashes.php',
    1 => 'stripcslashes',
  ),
  'next' => 
  array (
    0 => 'function.stripslashes.php',
    1 => 'stripslashes',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'ja',
    'path' => 'reference/strings/functions/stripos.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.stripos" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">stripos</h1>
  <p class="verinfo">(PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">stripos</span> &mdash; <span class="dc-title">大文字小文字を区別せずに文字列が最初に現れる位置を探す</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.stripos-description">
  <h3 class="title">説明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>stripos</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="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$offset</code><span class="initializer"> = 0</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">
   文字列 <code class="parameter">haystack</code> の中で
   <code class="parameter">needle</code> が最初に現れる位置を探します。
  </p>
  <p class="para">
   <span class="function"><a href="function.strpos.php" class="function">strpos()</a></span> と異なり、<span class="function"><strong>stripos()</strong></span>
   は大文字小文字を区別しません。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.stripos-parameters">
  <h3 class="title">パラメータ</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">haystack</code></dt>
     <dd>
      <p class="para">
       検索対象の文字列。
      </p>
     </dd>
    
    
     <dt><code class="parameter">needle</code></dt>
     <dd>
      <p class="para">
       検索する文字列。
      </p>
      
 <p class="para">
  PHP 8.0.0 より前のバージョンでは、<code class="parameter">needle</code> が文字列でない場合、
  数値に変換され、文字のコードポイントとして扱われていました。
  この振る舞いは PHP 7.3.0 以降では推奨されないので、
  この機能を使用しないことを強く推奨します。
  意図する動作に応じて、
  <code class="parameter">needle</code> を string に明示的にキャストするか、
  明示的に <span class="function"><a href="function.chr.php" class="function">chr()</a></span> 関数を呼び出すべきでしょう。
 </p>

     </dd>
    
    
     <dt><code class="parameter">offset</code></dt>
     <dd>
      <p class="para">
       指定すると、文字列内での検索開始位置がその位置になります。
       負の数を指定すると、文字列の末尾からこの数だけ戻った場所から検索を開始します。
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.stripos-returnvalues">
  <h3 class="title">戻り値</h3>
  <p class="para">
   needle が見つかった位置を、
   <code class="parameter">haystack</code> 文字列の先頭 (offset の値とは無関係) からの相対位置で返します。
   文字列の開始位置は 0 であり、1 ではないことに注意しましょう。
  </p>
  <p class="para">
   needle が見つからない場合は <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> を返します。
  </p>
  <div class="warning"><strong class="warning">警告</strong><p class="simpara">この関数は論理値
<strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> を返す可能性がありますが、<strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> として評価される値を返す可能性もあります。
詳細については <a href="language.types.boolean.php" class="link">論理値</a>の
セクションを参照してください。この関数の返り値を調べるには
<a href="language.operators.comparison.php" class="link">===演算子</a> を
使用してください。</p></div>
 </div>


 <div class="refsect1 errors" id="refsect1-function.stripos-errors">
  <h3 class="title">エラー / 例外</h3>
  <ul class="itemizedlist">
   <li class="listitem">
    <span class="simpara">
     <code class="parameter">offset</code> が <code class="parameter">haystack</code>
     の長さより大きい場合、
     <span class="classname"><a href="class.valueerror.php" class="classname">ValueError</a></span> がスローされます。
    </span>
   </li>
  </ul>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.stripos-changelog">
  <h3 class="title">変更履歴</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>バージョン</th>
      <th>説明</th>
     </tr>

    </thead>

    <tbody class="tbody">
     
 <tr>
  <td>8.2.0</td>
  <td>
   ケースフォールディングは、<span class="function"><a href="function.setlocale.php" class="function">setlocale()</a></span>
   で設定されたロケールに依存しなくなりました。
   ASCII のケースフォールディングのみが行われます。
   ASCII でないバイト列は、バイト値として比較されます。
  </td>
 </tr>


     <tr>
 <td>8.0.0</td>
 <td>
  <code class="parameter">needle</code> は、空文字列を受け入れるようになりました。
 </td>
</tr>

     <tr>
      <td>8.0.0</td>
      <td>
       <code class="parameter">needle</code> に数値を渡すことはサポートされなくなりました。
      </td>
     </tr>

     <tr>
      <td>7.3.0</td>
      <td>
       <code class="parameter">needle</code> に数値を渡すことは非推奨になりました。
      </td>
     </tr>

     <tr>
      <td>7.1.0</td>
      <td>
       負の <code class="parameter">offset</code> をサポートするようになりました。
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.stripos-examples">
  <h3 class="title">例</h3>
  <p class="para">
   <div class="example" id="example-1">
   <p><strong>例1 <span class="function"><strong>stripos()</strong></span> の例</strong></p>
    <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$findme    </span><span style="color: #007700">= </span><span style="color: #DD0000">'a'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$mystring1 </span><span style="color: #007700">= </span><span style="color: #DD0000">'xyz'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$mystring2 </span><span style="color: #007700">= </span><span style="color: #DD0000">'ABC'</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$pos1 </span><span style="color: #007700">= </span><span style="color: #0000BB">stripos</span><span style="color: #007700">(</span><span style="color: #0000BB">$mystring1</span><span style="color: #007700">, </span><span style="color: #0000BB">$findme</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$pos2 </span><span style="color: #007700">= </span><span style="color: #0000BB">stripos</span><span style="color: #007700">(</span><span style="color: #0000BB">$mystring2</span><span style="color: #007700">, </span><span style="color: #0000BB">$findme</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// いいえ、'a' は明らかに 'xyz' の中には存在しません<br /></span><span style="color: #007700">if (</span><span style="color: #0000BB">$pos1 </span><span style="color: #007700">=== </span><span style="color: #0000BB">false</span><span style="color: #007700">) {<br />    echo </span><span style="color: #DD0000">"The string '</span><span style="color: #0000BB">$findme</span><span style="color: #DD0000">' was not found in the string '</span><span style="color: #0000BB">$mystring1</span><span style="color: #DD0000">'"</span><span style="color: #007700">, </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #FF8000">// !== を使用していることに注意しましょう。単に != としても期待通りに動作<br />// しません。なぜなら 'a' は 0 番目(最初) の文字だからです。<br /></span><span style="color: #007700">if (</span><span style="color: #0000BB">$pos2 </span><span style="color: #007700">!== </span><span style="color: #0000BB">false</span><span style="color: #007700">) {<br />    echo </span><span style="color: #DD0000">"We found '</span><span style="color: #0000BB">$findme</span><span style="color: #DD0000">' in '</span><span style="color: #0000BB">$mystring2</span><span style="color: #DD0000">' at position </span><span style="color: #0000BB">$pos2</span><span style="color: #DD0000">"</span><span style="color: #007700">, </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

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


 <div class="refsect1 notes" id="refsect1-function.stripos-notes">
  <h3 class="title">注意</h3>
  <blockquote class="note"><p><strong class="note">注意</strong>: <span class="simpara">この関数はバイナリデータに対応しています。
</span></p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.stripos-seealso">
  <h3 class="title">参考</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.mb-stripos.php" class="function" rel="rdfs-seeAlso">mb_stripos()</a> - 大文字小文字を区別せず、
   文字列の中で指定した文字列が最初に現れる位置を探す</span></li>
    <li><span class="function"><a href="function.str-contains.php" class="function" rel="rdfs-seeAlso">str_contains()</a> - 指定された部分文字列が、文字列に含まれるかを調べる</span></li>
    <li><span class="function"><a href="function.str-ends-with.php" class="function" rel="rdfs-seeAlso">str_ends_with()</a> - 文字列が、指定された文字列で終わるかを調べる。</span></li>
    <li><span class="function"><a href="function.str-starts-with.php" class="function" rel="rdfs-seeAlso">str_starts_with()</a> - 文字列が指定された部分文字列で始まるかを調べる</span></li>
    <li><span class="function"><a href="function.strpos.php" class="function" rel="rdfs-seeAlso">strpos()</a> - 文字列内の部分文字列が最初に現れる場所を見つける</span></li>
    <li><span class="function"><a href="function.strrpos.php" class="function" rel="rdfs-seeAlso">strrpos()</a> - 文字列中に、ある部分文字列が最後に現れる場所を探す</span></li>
    <li><span class="function"><a href="function.strripos.php" class="function" rel="rdfs-seeAlso">strripos()</a> - 文字列中で、特定の(大文字小文字を区別しない)文字列が最後に現れた位置を探す</span></li>
    <li><span class="function"><a href="function.stristr.php" class="function" rel="rdfs-seeAlso">stristr()</a> - 大文字小文字を区別しない strstr</span></li>
    <li><span class="function"><a href="function.substr.php" class="function" rel="rdfs-seeAlso">substr()</a> - 文字列の一部分を返す</span></li>
    <li><span class="function"><a href="function.str-ireplace.php" class="function" rel="rdfs-seeAlso">str_ireplace()</a> - 大文字小文字を区別しない str_replace</span></li>
   </ul>
  </p>
 </div>


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