cvs: phpdoc-zh /features remote-files.xml
| From: | Gregory Song | Date: | Sun, 11 Aug 2002 00:35:33 +0000 |
| Subject: | cvs: phpdoc-zh /features remote-files.xml | ||
| Groups: | php.doc.zh | ||
| Request: | Send a blank email to doc-zh+get-294@lists.php.net to get a copy of this message | ||
gregory Sat Aug 10 20:35:33 2002 EDT
Modified files:
/phpdoc-zh/features remote-files.xml
Log:
Verbal Problem fixed...
Index: phpdoc-zh/features/remote-files.xml
diff -u phpdoc-zh/features/remote-files.xml:1.3 phpdoc-zh/features/remote-files.xml:1.4
--- phpdoc-zh/features/remote-files.xml:1.3 Sat Jul 20 19:35:10 2002
+++ phpdoc-zh/features/remote-files.xml Sat Aug 10 20:35:33 2002
@@ -1,48 +1,40 @@
-<?xml version="1.0" encoding="gb2312"?>
+<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.10 $ -->
-<!-- $AUTHOR$ -->
+<!-- $Author$ -->
<!-- EN-Revision: 1.18 Maintainer: thomaslio Status: ready -->
+<!-- CREDITS: Gregory -->
<chapter id="features.remote-files">
<title>ʹÓÃÔ¶³ÌÎļþ</title>
<para>
- ÐèÒªÖ§³Ö "URL fopen wrapper" ¹¦ÄÜ£¬ÄãÐèÅäÖÃPHP
- (³ý·ÇÄãÃ÷È·µÄʹÓÃ
- <option>--disable-url-fopen-wrapper</option>±êÖ¾(
- Ò»Ö±µ½°æ±¾
4.0.3)»òÕßÉèÖÃ<parameter>allow_url_fopen</parameter>ÔÚ &php.ini ¹Ø±Õ;
- (¶ÔÓÚа汾))£¬
- Äã¿ÉÒÔʹÓà HTTP ºÍ FTP µØÖ·ÔÚ¸ü¶àº¯ÊýÖУ¬Ò²¿ÉÒÔ°Ñ
- ÎļþÃû×÷Ϊ²ÎÊý£¬°üÀ¨<function>require</function>
- ºÍ <function>include</function>¡£
+ ÓÉÓÚ PHP ½¨Á¢ÁËÉèÖÃÖÐ¶Ô "URL fopen wrapper"
µÄÖ§³Ö£¨ÔÚ 4.0.3 ÒÔǰµÄ°æ±¾£¬Ã÷È·µÄʹÓÃ
<option>--disable-url-fopen-wrapper</option> ²ÎÊýÀ´±àÒë
PHP£¬»òÔÚа汾ÖУ¬½« &php.ini; ÎļþÖеÄ
<parameter>allow_url_fopen</parameter> ²ÎÊýÉèΪ
off£¬½«ÆÁ±Î¸Ã¹¦ÄÜ£©£¬Äú¿ÉÒÔÔÚ´ó¶àÊýÐèÒªÓÃÎļþÃû×÷Ϊ²ÎÊýµÄº¯ÊýÖÐʹÓÃ
HTTP ºÍ FTP URL À´´úÌæÎļþÃû£¬°üÀ¨ <function>require</function> ºÍ
<function>include</function> Óï¾ä¡£
</para>
<para>
<note>
<para>
- Windows°æ±¾µÄ
<literal>PHP</literal>ÔÚµ±Ç°²»Ö§³ÖÒÔϺ¯ÊýµÄ
- Ô¶³ÌÎļþ·ÃÎÊ:
- <function>include</function>£¬<function>include_once</function>£¬
- <function>require</function>ºÍ<function>require_once</function>¡£
+ Windows °æ±¾µÄ
<literal>PHP</literal>ÖУ¬ÒÔϺ¯Êýµ±Ç°²»Ö§³ÖÔ¶³ÌÎļþµÄ·ÃÎÊ£º
+
<function>include</function>¡¢<function>include_once</function>¡¢<function>require</function>
ºÍ <function>require_once</function>¡£
</para>
</note>
</para>
<para>
-
±ÈÈ磬Äã¿ÉÒÔʹÓÃÕâ¸öÔÚÔ¶³Ìweb·þÎñÆ÷´ò¿ªÒ»¸öÎļþ£¬½âÎöÄãÐèÒªÊä³öµÄÊý¾Ý£¬È»ºóʹÓÃÕâЩÊý¾ÝÔÚÊý¾Ý¿â»òÕß¼òµ¥µÄÊä³öµ½×°ÊÎÄãµÄÍøÕ¾¡£
+ ÀýÈ磬Äú¿ÉÒÔÓÃÒÔÏ·¶ÀýÀ´´ò¿ªÔ¶³Ì WEB
·þÎñÆ÷ÉϵÄÎļþ£¬½âÎöÄúÐèÒªµÄÊä³öÊý¾Ý£¬È»ºó½«ÕâЩÊý¾ÝÓÃÔÚÊý¾Ý¿âµÄ¼ìË÷ÖУ¬»òÕß¼òµ¥µØ½«ÆäÊä³öµ½ÄúÍøÕ¾Ê£ÏÂÄÚÈݵÄÑùʽƥÅäÖС£
</para>
<para>
<example>
- <title>»ñµÃÒ»¸öÔ¶³ÌÒ³ÃæµÄ±êÌâ</title>
+ <title>»ñȡԶ³ÌÎļþµÄ±êÌâ</title>
<programlisting role="php">
<![CDATA[
<?php
-$file = fopen ("http://www.example.com/"£¬ "r");
+$file = fopen ("http://www.example.com/",
"r");
if (!$file) {
echo "<p>Unable to open remote file.\n";
exit;
}
while (!feof ($file)) {
- $line = fgets ($file£¬ 1024);
+ $line = fgets ($file, 1024);
/* This only works if the title and its tags are on one line */
- if (eregi ("<title>(.*)</title>"£¬ $line£¬ $out)) {
+ if (eregi ("<title>(.*)</title>", $line, $out)) {
$title = $out[1];
break;
}
@@ -54,21 +46,28 @@
</example>
</para>
<para>
-
µ±ÄãÁ¬½Óµ½Ò»¸öÓµÓÐÇ¡µ±µÄ·ÃÎÊȨÏÞµÄFTPÒÔ¼°¸ÃÎļþ²»´æÔÚµÄʱºò£¬Äã¿ÉÒÔдÎļþ¡£ÔÚÓû§Á¬½ÓµÄʱºò£¬³ýÁË'ÄäÃû'£¬Äã±ØÐëÖ¸¶¨Ò»¸öÃû×Ö
(ÕýÈ·µÄÃÜÂë)ºÍµØÖ·£¬±ÈÈç'ftp://user:password@ftp.example.com/path/to/file'.(ËüÃÇÐèÒª»ù±¾µÄÈÏÖ¤£¬Äã¿ÉÒÔʹÓÃÏàͬµÄÓ﷨ȥ·ÃÎÊhttpµÄÎļþ¡£)
+
+ You can also write to files on an FTP as long you connect as a user
+ with the correct access rights, and the file doesn't exist already.
+ To connect as a user other than 'anonymous', you need to specify
+ the username (and possibly password) within the URL, such as
+ 'ftp://user:password@ftp.example.com/path/to/file'.
(You can use the
+ same sort of syntax to access files via HTTP when they require Basic
+ authentication.)
</para>
<para>
<example>
- <title>±£´æÊý¾Ýµ½Ô¶³Ì·þÎñÆ÷</title>
+ <title>Storing data on a remote server</title>
<programlisting role="php">
<![CDATA[
<?php
-$file = fopen ("ftp://ftp.example.com/incoming/outputfile"£¬
"w");
+$file = fopen ("ftp://ftp.example.com/incoming/outputfile",
"w");
if (!$file) {
echo "<p>Unable to open remote file for writing.\n";
exit;
}
/* Write the data here. */
-fputs ($file£¬ $_SERVER['HTTP_USER_AGENT'] . "\n");
+fputs ($file, $_SERVER['HTTP_USER_AGENT'] . "\n");
fclose ($file);
?>
]]>
@@ -78,8 +77,11 @@
<para>
<note>
<para>
-
Äã¿ÉÒÔ´ÓÉÏÃæµÄÀý×Ó»ñµÃÖ÷ÒâȥдԶ³Ì·ÃÎÊÈÕÖ¾¡£´ÓÒÔÉÏÀý×ÓÖУ¬Äã¿ÉÒÔÓÃfopen()дÄãËùϲ»¶µÄ·ÃÎÊÈÕÖ¾µÄ·½Ê½£¬ÄãÓ¦¸ÃÈ¥²Î¿¼
- <function>syslog</function>º¯Êý¡£
+ You might get the idea from the example above to use this
+ technique to write to a remote log, but as mentioned above, you
+ can only write to a new file using the URL fopen() wrappers. To
+ do distributed logging like that, you should take a look at
+ <function>syslog</function>.
</para>
</note>
</para>