<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML ><HEAD ><TITLE >iconv_strpos</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK REL="HOME" TITLE="PHP 手册" HREF="index.html"><LINK REL="UP" TITLE="iconv Functions" HREF="ref.iconv.html"><LINK REL="PREVIOUS" TITLE="iconv_strlen" HREF="function.iconv-strlen.html"><LINK REL="NEXT" TITLE="iconv_strrpos" HREF="function.iconv-strrpos.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8"></HEAD ><BODY CLASS="refentry" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >PHP 手册</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.iconv-strlen.html" ACCESSKEY="P" >上一页</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.iconv-strrpos.html" ACCESSKEY="N" >下一页</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="function.iconv-strpos" ></A >iconv_strpos</H1 ><DIV CLASS="refnamediv" ><A NAME="AEN84837" ></A ><P > (PHP 5)</P >iconv_strpos -- Finds position of first occurrence of a needle within a haystack</DIV ><DIV CLASS="refsect1" ><A NAME="AEN84840" ></A ><H2 >说明</H2 >int <B CLASS="methodname" >iconv_strpos</B > ( string haystack, string needle [, int offset [, string charset]] )<BR ></BR ><P > Finds position of first occurrence of a needle within a haystack. </P ><P > In contrast to <A HREF="function.strpos.html" ><B CLASS="function" >strpos()</B ></A >, the return value of <B CLASS="function" >iconv_strpos()</B > is the number of characters that appear before the needle, rather than the offset in bytes to the position where the needle has been found. The characters are counted on the basis of the specified character set <CODE CLASS="parameter" >charset</CODE >. </P ></DIV ><DIV CLASS="refsect1" ><A NAME="AEN84862" ></A ><H2 >参数</H2 ><P > <P ></P ><DIV CLASS="variablelist" ><DL ><DT ><CODE CLASS="parameter" >haystack</CODE ></DT ><DD ><P > The entire string. </P ></DD ><DT ><CODE CLASS="parameter" >needle</CODE ></DT ><DD ><P > The searched substring. </P ></DD ><DT ><CODE CLASS="parameter" >offset</CODE ></DT ><DD ><P > The optional <CODE CLASS="parameter" >offset</CODE > parameter specifies the position from which the search should be performed. </P ></DD ><DT ><CODE CLASS="parameter" >charset</CODE ></DT ><DD ><P > If <CODE CLASS="parameter" >charset</CODE > parameter is omitted, <CODE CLASS="parameter" >string</CODE > are assumed to be encoded in <A HREF="ref.iconv.html#iconv.configuration" >iconv.internal_encoding</A >. </P ></DD ></DL ></DIV > </P ><P > If <CODE CLASS="parameter" >haystack</CODE > or <CODE CLASS="parameter" >needle</CODE > is not a string, it is converted to a string and applied as the ordinal value of a character. </P ></DIV ><DIV CLASS="refsect1" ><A NAME="AEN84893" ></A ><H2 >返回值</H2 ><P > Returns the numeric position of the first occurrence of <CODE CLASS="parameter" >needle</CODE > in <CODE CLASS="parameter" >haystack</CODE >. </P ><P > If <CODE CLASS="parameter" >needle</CODE > is not found, <B CLASS="function" >iconv_strpos()</B > will return <TT CLASS="constant" ><B >FALSE</B ></TT >. </P ><DIV CLASS="warning" ><P ></P ><TABLE CLASS="warning" BORDER="1" WIDTH="100%" ><TR ><TD ALIGN="CENTER" ><B >警告</B ></TD ></TR ><TR ><TD ALIGN="LEFT" ><P >本函数可能返回布尔值 <TT CLASS="constant" ><B >FALSE</B ></TT >,但也可能返回一个与 <TT CLASS="constant" ><B >FALSE</B ></TT > 等值的非布尔值,例如 <TT CLASS="literal" >0</TT > 或者 ""。请参阅<A HREF="language.types.boolean.html" >布尔类型</A >章节以获取更多信息。应使用 <A HREF="language.operators.comparison.html" >=== 运算符</A >来测试本函数的返回值。</P ></TD ></TR ></TABLE ></DIV ></DIV ><DIV CLASS="refsect1" ><A NAME="AEN84909" ></A ><H2 >参见</H2 ><P > <P ></P ><TABLE BORDER="0" ><TBODY ><TR ><TD ><A HREF="function.strpos.html" ><B CLASS="function" >strpos()</B ></A ></TD ></TR ><TR ><TD ><A HREF="function.iconv-strrpos.html" ><B CLASS="function" >iconv_strrpos()</B ></A ></TD ></TR ><TR ><TD ><A HREF="function.mb-strpos.html" ><B CLASS="function" >mb_strpos()</B ></A ></TD ></TR ></TBODY ></TABLE ><P ></P > </P ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="function.iconv-strlen.html" ACCESSKEY="P" >上一页</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >起始页</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.iconv-strrpos.html" ACCESSKEY="N" >下一页</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >iconv_strlen</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="ref.iconv.html" ACCESSKEY="U" >上一级</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >iconv_strrpos</TD ></TR ></TABLE ></DIV ></BODY ></HTML >