mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2026-03-07 06:20:46 +08:00
0.0.1
This commit is contained in:
217
docs/php/gopher_parsedir.html
Normal file
217
docs/php/gopher_parsedir.html
Normal file
@@ -0,0 +1,217 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<title>Translate a gopher formatted directory entry into an associative array</title>
|
||||
</head>
|
||||
<body class="docs"><div id="layout">
|
||||
<div id="layout-content"><div id="function.gopher-parsedir" class="refentry">
|
||||
<div class="refnamediv">
|
||||
<h1 class="refname">gopher_parsedir</h1>
|
||||
<p class="verinfo">(PECL net_gopher >= 0.1)</p><p class="refpurpose"><span class="refname">gopher_parsedir</span> — <span class="dc-title">Translate a gopher formatted directory entry into an associative array</span></p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="refsect1 description" id="refsect1-function.gopher-parsedir-description">
|
||||
<h3 class="title">说明</h3>
|
||||
<div class="methodsynopsis dc-description">
|
||||
<span class="methodname"><strong>gopher_parsedir</strong></span>
|
||||
( <span class="methodparam"><span class="type">string</span> <code class="parameter">$dirent</code></span>
|
||||
) : <span class="type">array</span></div>
|
||||
|
||||
<p class="para rdfs-comment">
|
||||
<span class="function"><strong>gopher_parsedir()</strong></span> parses a gopher formatted directory
|
||||
entry into an associative array.
|
||||
</p>
|
||||
<p class="para">
|
||||
While gopher returns <em>text/plain</em> 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 parameters" id="refsect1-function.gopher-parsedir-parameters">
|
||||
<h3 class="title">参数</h3>
|
||||
<p class="para">
|
||||
<dl>
|
||||
|
||||
|
||||
<dt>
|
||||
<code class="parameter">dirent</code></dt>
|
||||
|
||||
<dd>
|
||||
|
||||
<p class="para">
|
||||
The directory entry.
|
||||
</p>
|
||||
</dd>
|
||||
|
||||
|
||||
</dl>
|
||||
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="refsect1 returnvalues" id="refsect1-function.gopher-parsedir-returnvalues">
|
||||
<h3 class="title">返回值</h3>
|
||||
<p class="para">
|
||||
Returns an associative array whose components are:
|
||||
<ul class="itemizedlist">
|
||||
<li class="listitem">
|
||||
<span class="simpara">
|
||||
<em>type</em> - One of the
|
||||
<em>GOPHER_XXX</em> constants.
|
||||
</span>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<span class="simpara">
|
||||
<em>title</em> - The name of the resource.
|
||||
</span>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<span class="simpara">
|
||||
<em>path</em> - The path of the resource.
|
||||
</span>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<span class="simpara">
|
||||
<em>host</em> - The domain name of the host that has
|
||||
this document (or directory).
|
||||
</span>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<span class="simpara">
|
||||
<em>port</em> - The port at which to connect on
|
||||
<em>host</em>.
|
||||
</span>
|
||||
</li>
|
||||
</ul>
|
||||
</p>
|
||||
<p class="para">
|
||||
Upon failure, the additional <em>data</em> entry of the
|
||||
returned array will hold the parsed line.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="refsect1 examples" id="refsect1-function.gopher-parsedir-examples">
|
||||
<h3 class="title">范例</h3>
|
||||
<p class="para">
|
||||
<div class="example" id="example-5363">
|
||||
<p><strong>Example #1 Hypothetical output from <em>gopher://gopher.example.com/</em></strong></p>
|
||||
<div class="example-contents screen">
|
||||
<div class="cdata"><pre>
|
||||
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></div>
|
||||
</div>
|
||||
</div>
|
||||
</p>
|
||||
<p class="para">
|
||||
In the example above, the root directory at gopher.example.com knows about
|
||||
one <em>DOCUMENT</em> identified by <em>0</em> located at
|
||||
<em>gopher://gopher.example.com:70/allabout.txt</em>. It also knows
|
||||
about two other directory (which have their own listing files) at
|
||||
<em>gopher://gopher.exmaple.com:70/stories</em> and at
|
||||
<em>gopher://gopher.ejemplo.co.es:70/</em>.
|
||||
In addition there is a binary file, a link to an HTTP url, and several
|
||||
informative lines.
|
||||
</p>
|
||||
<p class="para">
|
||||
By passing each line of the directory listing into
|
||||
<span class="function"><strong>gopher_parsedir()</strong></span>, an associative array is formed containing
|
||||
a parsed out version of the data.
|
||||
</p>
|
||||
<p class="para">
|
||||
<div class="example" id="example-5364">
|
||||
<p><strong>Example #2 Using <span class="function"><strong>gopher_parsedir()</strong></span></strong></p>
|
||||
<div class="example-contents">
|
||||
<div class="phpcode"><pre><span style="color: #000000">
|
||||
<span style="color: #0000BB"><?php<br />$directory </span><span style="color: #007700">= </span><span style="color: #0000BB">file</span><span style="color: #007700">(</span><span style="color: #DD0000">"gopher://gopher.example.com"</span><span style="color: #007700">);<br /><br />foreach(</span><span style="color: #0000BB">$directory </span><span style="color: #007700">as </span><span style="color: #0000BB">$dirent</span><span style="color: #007700">) {<br /> </span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">gopher_parsedir</span><span style="color: #007700">(</span><span style="color: #0000BB">$dirent</span><span style="color: #007700">));<br />}<br /></span><span style="color: #0000BB">?></span>
|
||||
</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
|
||||
<div class="example-contents"><p>以上例程会输出:</p></div>
|
||||
<div class="example-contents screen">
|
||||
<div class="cdata"><pre>
|
||||
Array (
|
||||
[type] => 0
|
||||
[title] => All about my gopher site.
|
||||
[path] => /allabout.txt
|
||||
[host] => gopher.example.com
|
||||
[port] => 70
|
||||
)
|
||||
Array (
|
||||
[type] => 9
|
||||
[title] => A picture of my cat.
|
||||
[path] => /pics/cat.png
|
||||
[host] => gopher.example.com
|
||||
[port] => 70
|
||||
)
|
||||
Array (
|
||||
[type] => 1
|
||||
[title] => A collection of my writings.
|
||||
[path] => /stories
|
||||
[host] => gopher.example.com
|
||||
[port] => 70
|
||||
)
|
||||
Array (
|
||||
[type] => 254
|
||||
[title] => The HTTP version of this site.
|
||||
[path] => URL:http://www.example.com
|
||||
[host] => gopher.example.com
|
||||
[port] => 70
|
||||
)
|
||||
Array (
|
||||
[type] => 1
|
||||
[title] => Mirror of this site in Spain.
|
||||
[path] => /
|
||||
[host] => gopher.ejemplo.co.es
|
||||
[port] => 70
|
||||
)
|
||||
Array (
|
||||
[type] => 255
|
||||
[title] => Welcome to my gopher site.
|
||||
[path] =>
|
||||
[host] => error.host
|
||||
[port] => 1
|
||||
)
|
||||
Array (
|
||||
[type] => 255
|
||||
[title] => Please select one of the options above.
|
||||
[path] =>
|
||||
[host] => error.host
|
||||
[port] => 1
|
||||
)
|
||||
Array (
|
||||
[type] => 255
|
||||
[title] => Send complaints to /dev/null
|
||||
[path] =>
|
||||
[host] => error.host
|
||||
[port] => 1
|
||||
)
|
||||
Array (
|
||||
[type] => 255
|
||||
[title] => Long live gopher!
|
||||
[path] =>
|
||||
[host] => error.host
|
||||
[port] => 1
|
||||
)
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
</div></div></div></body></html>
|
||||
Reference in New Issue
Block a user