⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 function.stripos.html

📁 php的帮助文档,涉及到PHP的案例和基本语法,以及实际应用内容
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head>  <title>Find position of first occurrence of a case-insensitive string</title>  <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.stripcslashes.html">stripcslashes</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.stripslashes.html">stripslashes</a></div> <div class="up"><a href="ref.strings.html">String Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="function.stripos" class="refentry"> <div class="refnamediv">  <h1 class="refname">stripos</h1>  <p class="verinfo">(PHP 5)</p><p class="refpurpose"><span class="refname">stripos</span> &mdash; <span class="dc-title">Find position of first occurrence of a case-insensitive string</span></p> </div>  <div class="refsect1 description">  <h3 class="title">Description</h3>  <div class="methodsynopsis dc-description">   <span class="type">int</span> <span class="methodname"><b><b>stripos</b></b></span>    ( <span class="methodparam"><span class="type">string</span> <tt class="parameter">$haystack</tt></span>   , <span class="methodparam"><span class="type">string</span> <tt class="parameter">$needle</tt></span>   [, <span class="methodparam"><span class="type">int</span> <tt class="parameter">$offset</tt></span>  ] )</div>  <p class="para rdfs-comment">   Returns the numeric position of the first occurrence of   <i><tt class="parameter">needle</tt></i> in the <i><tt class="parameter">haystack</tt></i>   <a href="language.types.string.html" class="type string">string</a>.  </p>  <p class="para">   Unlike <a href="function.strpos.html" class="function">strpos()</a>, <b>stripos()</b> is   case-insensitive.  </p> </div> <div class="refsect1 parameters">  <h3 class="title">Parameters</h3>  <p class="para">   <dl>    <dt>     <span class="term"><i><tt class="parameter">haystack</tt></i></span>     <dd>      <p class="para">       The string to search in      </p>     </dd>    </dt>    <dt>     <span class="term"><i><tt class="parameter">needle</tt></i></span>     <dd>      <p class="para">       Note that the <i><tt class="parameter">needle</tt></i> may be a string of one or       more characters.      </p>      <p class="para">       If <i><tt class="parameter">needle</tt></i> is not a string, it is converted to       an integer and applied as the ordinal value of a character.      </p>     </dd>    </dt>    <dt>     <span class="term"><i><tt class="parameter">offset</tt></i></span>     <dd>      <p class="para">       The optional <i><tt class="parameter">offset</tt></i> parameter allows you       to specify which character in <i><tt class="parameter">haystack</tt></i> to       start searching. The position returned is still relative to the       beginning of <i><tt class="parameter">haystack</tt></i>.      </p>     </dd>    </dt>   </dl>  </p> </div> <div class="refsect1 returnvalues">  <h3 class="title">Return Values</h3>  <p class="para">   If <i><tt class="parameter">needle</tt></i> is not found,   <b>stripos()</b> will return <a href="language.types.boolean.html" class="type boolean">boolean</a> <b><tt>FALSE</tt></b>.  </p>  <div class="warning"><b class="warning">Warning</b><p class="simpara">This function mayreturn Boolean <b><tt>FALSE</tt></b>, but may also return a non-Boolean value whichevaluates to <b><tt>FALSE</tt></b>, such as <i>0</i> or&quot;&quot;. Please read the section on <a href="language.types.boolean.html" class="link">Booleans</a> for moreinformation. Use <a href="language.operators.comparison.html" class="link">the ===operator</a> for testing the return value of thisfunction.</p></div> </div> <div class="refsect1 examples">  <h3 class="title">Examples</h3>  <p class="para">   <div class="example">   <p><b>Example #1 <b>stripos()</b> examples</b></p>    <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$findme&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'a'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$mystring1&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'xyz'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$mystring2&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'ABC'</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$pos1&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">stripos</span><span style="color: #007700">(</span><span style="color: #0000BB">$mystring1</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$findme</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$pos2&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">stripos</span><span style="color: #007700">(</span><span style="color: #0000BB">$mystring2</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$findme</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;Nope,&nbsp;'a'&nbsp;is&nbsp;certainly&nbsp;not&nbsp;in&nbsp;'xyz'<br /></span><span style="color: #007700">if&nbsp;(</span><span style="color: #0000BB">$pos1&nbsp;</span><span style="color: #007700">===&nbsp;</span><span style="color: #0000BB">false</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"The&nbsp;string&nbsp;'$findme'&nbsp;was&nbsp;not&nbsp;found&nbsp;in&nbsp;the&nbsp;string&nbsp;'$mystring1'"</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #FF8000">//&nbsp;Note&nbsp;our&nbsp;use&nbsp;of&nbsp;===.&nbsp;&nbsp;Simply&nbsp;==&nbsp;would&nbsp;not&nbsp;work&nbsp;as&nbsp;expected<br />//&nbsp;because&nbsp;the&nbsp;position&nbsp;of&nbsp;'a'&nbsp;is&nbsp;the&nbsp;0th&nbsp;(first)&nbsp;character.<br /></span><span style="color: #007700">if&nbsp;(</span><span style="color: #0000BB">$pos2&nbsp;</span><span style="color: #007700">!==&nbsp;</span><span style="color: #0000BB">false</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"We&nbsp;found&nbsp;'$findme'&nbsp;in&nbsp;'$mystring2'&nbsp;at&nbsp;position&nbsp;$pos2"</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">  <h3 class="title">Notes</h3>  <blockquote><p><b class="note">Note</b>: <span class="simpara">This function isbinary-safe.</span></p></blockquote> </div> <div class="refsect1 seealso">  <h3 class="title">See Also</h3>  <p class="para">   <ul class="simplelist">    <li class="member"><a href="function.strpos.html" class="function" rel="rdfs-seeAlso">strpos()</a></li>    <li class="member"><a href="function.strrpos.html" class="function" rel="rdfs-seeAlso">strrpos()</a></li>    <li class="member"><a href="function.strrchr.html" class="function" rel="rdfs-seeAlso">strrchr()</a></li>    <li class="member"><a href="function.substr.html" class="function" rel="rdfs-seeAlso">substr()</a></li>    <li class="member"><a href="function.stristr.html" class="function" rel="rdfs-seeAlso">stristr()</a></li>    <li class="member"><a href="function.strstr.html" class="function" rel="rdfs-seeAlso">strstr()</a></li>    <li class="member"><a href="function.strripos.html" class="function" rel="rdfs-seeAlso">strripos()</a></li>    <li class="member"><a href="function.str-ireplace.html" class="function" rel="rdfs-seeAlso">str_ireplace()</a></li>   </ul>  </p> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.stripcslashes.html">stripcslashes</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.stripslashes.html">stripslashes</a></div> <div class="up"><a href="ref.strings.html">String Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -