Sophie

Sophie

distrib > Mandriva > 2008.1 > x86_64 > by-pkgid > 05cd670d8a02b2b4a0ffb1756f2e8308 > files > 6552

php-manual-zh-5.2.4-1mdv2008.1.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>gopher_parsedir</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REL="HOME"
TITLE="PHP 手册"
HREF="index.html"><LINK
REL="UP"
TITLE="Net_Gopher"
HREF="ref.net-gopher.html"><LINK
REL="PREVIOUS"
TITLE="Net_Gopher"
HREF="ref.net-gopher.html"><LINK
REL="NEXT"
TITLE="Haru PDF Functions"
HREF="ref.haru.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="ref.net-gopher.html"
ACCESSKEY="P"
>上一页</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="ref.haru.html"
ACCESSKEY="N"
>下一页</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="function.gopher-parsedir"
></A
>gopher_parsedir</H1
><DIV
CLASS="refnamediv"
><A
NAME="AEN66071"
></A
><P
>    (PECL)</P
>gopher_parsedir&nbsp;--&nbsp;Translate a gopher formatted directory entry into an associative array.</DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN66074"
></A
><H2
>说明</H2
>array <B
CLASS="methodname"
>gopher_parsedir</B
> ( string dirent )<BR
></BR
><P
>&#13;   <B
CLASS="function"
>gopher_parsedir()</B
> parses a gopher formatted directory
   entry into an associative array.
  </P
><P
>&#13;   While gopher returns <TT
CLASS="literal"
>text/plain</TT
> documents for
   actual document requests. A request to a directory (such as /) will
   return specially encoded series of lines with each line being one
   directory entry or information line.
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN66086"
></A
><H2
>参数</H2
><P
>&#13;   <P
></P
><DIV
CLASS="variablelist"
><DL
><DT
><CODE
CLASS="parameter"
>dirent</CODE
></DT
><DD
><P
>&#13;       The directory entry.
      </P
></DD
></DL
></DIV
>
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN66095"
></A
><H2
>返回值</H2
><P
>&#13;   Returns an associative array whose components are: 
   <P
></P
><UL
><LI
><P
>&#13;      <CODE
CLASS="structfield"
>type</CODE
> - One of the 
      <TT
CLASS="literal"
>GOPHER_XXX</TT
> constants.
     </P
></LI
><LI
><P
>&#13;      <CODE
CLASS="structfield"
>title</CODE
> - The name of the resource.
     </P
></LI
><LI
><P
>&#13;      <CODE
CLASS="structfield"
>path</CODE
> - The path of the resource.
     </P
></LI
><LI
><P
>&#13;      <CODE
CLASS="structfield"
>host</CODE
> - The domain name of the host that has
      this document (or directory).
     </P
></LI
><LI
><P
>&#13;      <CODE
CLASS="structfield"
>port</CODE
> - The port at which to connect on
      <CODE
CLASS="structfield"
>host</CODE
>.
     </P
></LI
></UL
>
  </P
><P
>&#13;   Upon failure, the additional <CODE
CLASS="structfield"
>data</CODE
> entry of the
   returned array will hold the parsed line.
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN66118"
></A
><H2
>范例</H2
><P
>&#13;   <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN66121"
></A
><P
><B
>例 1. Hypothetical output from <TT
CLASS="literal"
>gopher://gopher.example.com/</TT
></B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="screen"
>0All about my gopher site.	/allabout.txt	gopher.example.com	70
9A picture of my cat.	/pics/cat.png	gopher.example.com	70
1A collection of my writings.	/stories	gopher.example.com	70
hThe HTTP version of this site.	URL:http://www.example.com	gopher.example.com	70
1Mirror of this site in Spain.	/	gopher.ejemplo.co.es	70
iWelcome to my gopher site.		error.host	1
iPlease select one of the options above		error.host	1
iSend complaints to /dev/null		error.host	1
iLong live gopher!		error.host	1</PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
  </P
><P
>&#13;   In the example above, the root directory at gopher.example.com knows about
   one <TT
CLASS="literal"
>DOCUMENT</TT
> identified by <TT
CLASS="literal"
>0</TT
> located at
   <TT
CLASS="literal"
>gopher://gopher.example.com:70/allabout.txt</TT
>.  It also knows
   about two other directory (which have their own listing files) at
   <TT
CLASS="literal"
>gopher://gopher.exmaple.com:70/stories</TT
> and at
   <TT
CLASS="literal"
>gopher://gopher.ejemplo.co.es:70/</TT
>.
   In addition there is a binary file, a link to an HTTP url, and several
   informative lines.
  </P
><P
>&#13;   By passing each line of the directory listing into 
   <B
CLASS="function"
>gopher_parsedir()</B
>, an associative array is formed containing
   a parsed out version of the data.
  </P
><P
>&#13;   <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN66134"
></A
><P
><B
>例 2. Using <B
CLASS="function"
>gopher_parsedir()</B
></B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br />$directory </font><font color="#007700">= </font><font color="#0000BB">file</font><font color="#007700">(</font><font color="#DD0000">"gopher://gopher.example.com"</font><font color="#007700">);<br /><br />foreach(</font><font color="#0000BB">$directory </font><font color="#007700">as </font><font color="#0000BB">$dirent</font><font color="#007700">) {<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">print_r</font><font color="#007700">(</font><font color="#0000BB">gopher_parsedir</font><font color="#007700">(</font><font color="#0000BB">$dirent</font><font color="#007700">));<br />}<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
><P
>上例将输出:</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="screen"
>Array (
  [type] =&#62; 0
  [title] =&#62; All about my gopher site.
  [path] =&#62; /allabout.txt
  [host] =&#62; gopher.example.com
  [port] =&#62; 70
)
Array (
  [type] =&#62; 9
  [title] =&#62; A picture of my cat.
  [path] =&#62; /pics/cat.png
  [host] =&#62; gopher.example.com
  [port] =&#62; 70
)
Array (
  [type] =&#62; 1
  [title] =&#62; A collection of my writings.
  [path] =&#62; /stories
  [host] =&#62; gopher.example.com
  [port] =&#62; 70
)
Array (
  [type] =&#62; 254
  [title] =&#62; The HTTP version of this site.
  [path] =&#62; URL:http://www.example.com
  [host] =&#62; gopher.example.com
  [port] =&#62; 70
)
Array (
  [type] =&#62; 1
  [title] =&#62; Mirror of this site in Spain.
  [path] =&#62; /
  [host] =&#62; gopher.ejemplo.co.es
  [port] =&#62; 70
)
Array (
  [type] =&#62; 255
  [title] =&#62; Welcome to my gopher site.
  [path] =&#62;
  [host] =&#62; error.host
  [port] =&#62; 1
)
Array (
  [type] =&#62; 255
  [title] =&#62; Please select one of the options above.
  [path] =&#62;
  [host] =&#62; error.host
  [port] =&#62; 1
)
Array (
  [type] =&#62; 255
  [title] =&#62; Send complaints to /dev/null
  [path] =&#62;
  [host] =&#62; error.host
  [port] =&#62; 1
)
Array (
  [type] =&#62; 255
  [title] =&#62; Long live gopher!
  [path] =&#62;
  [host] =&#62; error.host
  [port] =&#62; 1
)</PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
  </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="ref.net-gopher.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="ref.haru.html"
ACCESSKEY="N"
>下一页</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Net_Gopher</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="ref.net-gopher.html"
ACCESSKEY="U"
>上一级</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Haru PDF Functions</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>