cvs: phpdoc-zh /reference/stream/functions stream-get-meta-data.xml stream-register-wrapper.xml stream-wrapper-register.xml

From: Date: Thu, 07 Jul 2005 09:37:20 +0000
Subject: cvs: phpdoc-zh /reference/stream/functions stream-get-meta-data.xml stream-register-wrapper.xml stream-wrapper-register.xml
Groups: php.doc.zh 
Request: Send a blank email to doc-zh+get-2010@lists.php.net to get a copy of this message
yincheng Thu Jul 7 05:37:20 2005 EDT Added files: /phpdoc-zh/reference/stream/functions stream-get-meta-data.xml stream-register-wrapper.xml stream-wrapper-register.xml Log: ´ËĿ¼µÄÎļþÊÇ´Ófilesystemº¯ÊýĿ¼·ÖÀë³öÀ´µÄ¡£ ÔÚÓ¢ÎİæÄ¿Â¼·ÖÀëǰ£¬ÒѾ­ÓÐÈçϵÄÁ½¸öÎļþÒѾ­·­Òë¡£ ´Ë´ÎÌá½»ÊǰÑÕâÁ½¸öÎļþ¼ÓÈëµ½Õâ¸öĿ¼ÖУ¬²¢½« stream-register-wrapper¿½±´Îªstream-wrapper-register¡£ ÇëºóÐø·­ÒëÕß×¢Òâ¡£

http://cvs.php.net/co.php/phpdoc-zh/reference/stream/functions/stream-get-meta-data.xml?r=1.1&p=1 Index: phpdoc-zh/reference/stream/functions/stream-get-meta-data.xml +++ phpdoc-zh/reference/stream/functions/stream-get-meta-data.xml <?xml version="1.0" encoding="gb2312"?> <!-- $Revision: 1.1 $ --> <!-- $Author: yincheng $ --> <!-- EN-Revision: 1.1 Maintainer: dallas Status: ready --> <refentry id="function.stream-get-meta-data"> <refnamediv> <refname>stream_get_meta_data</refname> <refpurpose>´Ó·âװЭÒéÎļþÖ¸ÕëÖÐÈ¡µÃ±¨Í·£¯ÔªÊý¾Ý</refpurpose> </refnamediv> <refsect1> <title>˵Ã÷</title> <methodsynopsis> <type>mixed</type><methodname>stream_get_meta_data</methodname> <methodparam><type>int</type><parameter>fp</parameter></methodparam> </methodsynopsis> <simpara> ·µ»ØÏÖÓÐ <parameter>stream</parameter> µÄÐÅÏ¢¡£¿ÉÒÔÊÇÈκÎͨ¹ý <function>fopen</function>£¬<function>fsockopen</function> ºÍ <function>pfsockopen</function> ½¨Á¢µÄÁ÷¡£·µ»ØµÄÊý×é°üº¬ÒÔÏÂÏîÄ¿£º </simpara> <itemizedlist> <listitem> <para> <parameter>timed_out</parameter> (bool) - Èç¹ûÔÚÉϴε÷Óà <function>fread</function> »òÕß <function>fgets</function> ÖеȴýÊý¾ÝʱÁ÷³¬Ê±ÁËÔòΪ &true;¡£ </para> </listitem> <listitem> <para> <parameter>blocked</parameter> (bool) - Èç¹ûÁ÷´¦ÓÚ×èÈû IO ģʽʱΪ &true;¡£²Î¼û <function>socket_set_blocking</function>¡£ </para> </listitem> <listitem> <para> <parameter>eof</parameter> (bool) - Èç¹ûÁ÷µ½´ïÎļþĩβʱΪ &true;¡£×¢Òâ¶ÔÓÚ socket Á÷ÉõÖÁµ± <parameter>unread_bytes</parameter> Ϊ·ÇÁãֵʱҲ¿ÉÒÔΪ &true;¡£Òª²â¶¨ÊÇ·ñÓиü¶àÊý¾Ý¿É¶Á£¬Óà <function>feof</function> Ìæ´ú¶ÁÈ¡±¾ÏîÄ¿µÄÖµ¡£ </para> </listitem> <listitem> <para> <parameter>unread_bytes</parameter> (int) - µ±Ç°¶ÁÈ¡»º³åÇøÖеÄ×Ö½ÚÊý¡£ </para> </listitem> </itemizedlist> <simpara> ÒÔÏÂÏîÄ¿ÊÇ PHP 4.3 мӵģº </simpara> <itemizedlist> <listitem> <para> <parameter>stream_type</parameter> (string) - Ò»¸öÃèÊöÁ÷µ×²ãʵÏֵıê×¢¡£ </para> </listitem> <listitem> <para> <parameter>wrapper_type</parameter> (string) - Ò»¸öÃèÊöÁ÷µÄ·Ö²ãЭÒé·âװʵÏֵıê×¢¡£¸ü¶à¹ØÓÚ·âװЭÒéµÄÐÅÏ¢¼û <xref linkend="wrappers"/>¡£ </para> </listitem> <listitem> <para> <parameter>wrapper_data</parameter> (mixed) - µ±Ç°Á÷¸½¼ÓµÄ·âװЭÒéÊý¾Ý¡£¸ü¶à·âװЭÒé¼°ÆäÊý¾ÝµÄÐÅÏ¢¼û <xref linkend="wrappers"/>¡£ </para> </listitem> <listitem> <para> <parameter>filters</parameter> (array) - °üº¬Óб»µþ¼ÓÔÚµ±Ç°Á÷µÄÈκιýÂËÆ÷ÃûµÄÊý×é¡£¹ýÂËÆ÷ĿǰûÓÐÎĵµ¡£ </para> </listitem> </itemizedlist> <note> <para> ±¾º¯ÊýÊÇ PHP 4.3 Òý½øµÄ£¬Ôڴ˰汾֮ǰ£¬¿ÉÒÔÓà <function>socket_get_status</function> À´È¡µÃǰËĸöÏîÄ¿²¢ÇÒ<emphasis>½öÄÜÓÃÓÚ»ùÓÚ socket µÄÁ÷</emphasis>¡£ </para> <para> ÔÚ PHP 4.3 ¼°ÒÔºó°æ±¾ÖУ¬<function>socket_get_status</function> ÊDZ¾º¯ÊýµÄ±ðÃû¡£ </para> </note> <note> <simpara> ±¾º¯Êý²»ÄÜ×÷ÓÃÓÚͨ¹ý <link linkend="ref.sockets">Socket À©Õ¹¿â</link>´´½¨µÄÁ÷¡£ </simpara> </note> </refsect1> </refentry> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> http://cvs.php.net/co.php/phpdoc-zh/reference/stream/functions/stream-register-wrapper.xml?r=1.1&p=1 Index: phpdoc-zh/reference/stream/functions/stream-register-wrapper.xml +++ phpdoc-zh/reference/stream/functions/stream-register-wrapper.xml <?xml version="1.0" encoding="gb2312"?> <!-- $Revision: 1.1 $ --> <!-- $Author: yincheng $ --> <!-- EN-Revision: 1.1 Maintainer: dallas Status: ready --> <refentry id="function.stream-register-wrapper"> <refnamediv> <refname>stream_register_wrapper</refname> <refpurpose>×¢²áÒ»¸öÓà PHP ÀàʵÏÖµÄ URL ·âװЭÒé</refpurpose> </refnamediv> <refsect1> <title>˵Ã÷</title> <methodsynopsis> <type>boolean</type><methodname>stream_register_wrapper</methodname> <methodparam><type>string</type><parameter>protocol</parameter></methodparam> <methodparam><type>string</type><parameter>classname</parameter></methodparam> </methodsynopsis> <para> <function>stream_register_wrapper</function> ÔÊÐíÓû§ÊµÏÖ×Ô¶¨ÒåµÄЭÒé´¦ÀíÆ÷ºÍÁ÷£¬ÓÃÓÚËùÓÐÆäËüµÄÎļþϵͳº¯ÊýÖУ¨ÀýÈç <function>fopen</function>£¬<function>fread</function> µÈ£©¡£ </para> <para> ҪʵÏÖÒ»¸ö·âװЭÒ飬ÐèÒª°´ÕÕÈç϶¨ÒåÉùÃ÷Ò»¸ö°üº¬ÓÐһЩº¯ÊýµÄÀà¡£µ±ÓÐÈ˶ÔÄãµÄÁ÷ʹÓà fopen ʱ£¬PHP ½«´´½¨Ò»¸ö <parameter>classname</parameter> µÄʵÀý²¢µ÷ÓøÃʵÀýµÄ·½·¨¡£±ØÐëÑϸñ°´ÕÕÈçϵÄÃèÊöʵÏÖ·½·¨ - ·ñÔò½«µ¼Ö²»Ã÷È·µÄÐÐΪ¡£ </para> <para> Èç¹û <parameter>protocol</parameter> ÒѾ­ÓÐÁË´¦ÀíЭÒ飬Ôò <function>stream_register_wrapper</function> ½«·µ»Ø &false;¡£ </para> <methodsynopsis> <type>boolean</type><methodname>stream_open</methodname> <methodparam><type>string</type><parameter>path</parameter></methodparam> <methodparam><type>string</type><parameter>mode</parameter></methodparam> <methodparam><type>int</type><parameter>options</parameter></methodparam> <methodparam><type>string</type><parameter>opened_path</parameter></methodparam> </methodsynopsis> <para> µ±ÄãµÄÁ÷¶ÔÏó±»´´½¨Ö®ºóÁ¢¼´»áµ÷Óô˷½·¨¡£<parameter>path</parameter> Ö¸¶¨ÁË´«Èë <function>fopen</function> ÒÔ¼°´Ë¶ÔÏóÐèҪȡ»ØµÄ URL¡£¿ÉÒÔÓà <function>parse_url</function> À´½«´Ë URL ·Ö¸î³É¼¸²¿·Ö¡£ </para> <para> <parameter>mode</parameter> ÓÃÀ´´ò¿ªÎļþµÄģʽ£¬ºÍ <function>fopen</function> ÖеÄÒ»Ñù¡£ÄãÓÐÔðÈμì²é <parameter>mode</parameter> ¶ÔÓÚËùÇëÇóµÄ <parameter>path</parameter> ÊÇ·ñºÏ·¨¡£ </para> <para> <parameter>options</parameter> ±£´æÁËͨ¹ýÁ÷ API É趨µÄ¸½¼Ó±êÖ¾¡£¿ÉÒÔ±£´æÒÔÏÂÒ»¸öÖµ»òÕßÓà OR ºÏ²¢µÄ¶à¸öÖµ¡£ <informaltable> <tgroup cols="2"> <thead> <row> <entry>±êÖ¾</entry> <entry>˵Ã÷</entry> </row> </thead> <tbody> <row> <entry>STREAM_USE_PATH</entry> <entry>Èç¹û <parameter>path</parameter> ÊÇÏà¶Ô·¾¶£¬ÔòÓà include_path ËÑË÷×ÊÔ´¡£ </entry> </row> <row> <entry>STREAM_REPORT_ERRORS</entry> <entry>Èç¹ûÉ趨Á˱¾±êÖ¾£¬ÄãÓÐÔðÈÎÔÚ´ò¿ªÁ÷ʱÓà <function>trigger_error</function> À´»½Æð´íÎó¡£Èç¹ûûÓÐÉ趨Õâ¸ö±êÖ¾£¬ÄÇôÄã²»ÐèÒª»½ÆðÈκδíÎó¡£ </entry> </row> </tbody> </tgroup> </informaltable> </para> <para> Èç¹û³É¹¦´ò¿ªÁË <parameter>path</parameter>£¬²¢ÇÒÔÚ <parameter>options</parameter> ÖÐÉ趨ÁË STREAM_USE_PATH£¬ÄãÐèÒª½« <parameter>opened_path</parameter> É趨Ϊʵ¼Ê±»´ò¿ªµÄÎļþ£¯×ÊÔ´µÄÍêÕû·¾¶¡£ </para> <para> Èç¹û³É¹¦´ò¿ªÁËËùÇëÇóµÄ×ÊÔ´£¬Ó¦¸Ã·µ»Ø &true;£¬·ñÔò·µ»Ø &false;¡£ </para> <methodsynopsis> <type>void</type><methodname>stream_close</methodname> <methodparam><type>void</type><parameter></parameter></methodparam> </methodsynopsis> <para> ±¾·½·¨ÔÚÁ÷¹Ø±Õʱ±»µ÷Óã¬Ê¹Óà <function>fclose</function>¡£±ØÐëÊͷű»Á÷Ëø¶¨»ò·ÖÅäµÄÈκÎ×ÊÔ´¡£ </para> <methodsynopsis> <type>string</type><methodname>stream_read</methodname> <methodparam><type>int</type><parameter>count</parameter></methodparam> </methodsynopsis> <para> µ±¶ÔÁ÷½øÐÐ <function>fread</function> ºÍ <function>fgets</function> ²Ù×÷ʱ±¾·½·¨±»µ÷ÓᣱØÐë´Óµ±Ç°¶ÁдλÖÃÒÔ×Ö·û´®·µ»Ø×î¶à <parameter>count</parameter> ×Ö½ÚµÄÊý¾Ý¡£Èç¹û¿ÉÓÃÊý¾ÝÉÙÓÚ <parameter>count</parameter> ×Ö½Ú£¬Ôò·µ»Ø¾¡¿ÉÄܶàµÄÊý¾Ý¡£Èç¹ûûÓпɹ©·µ»ØµÄÊý¾Ý£¬·µ»Ø &false; »òÕß¿Õ×Ö·û´®¡£±ØÐëÓóɹ¦¶ÁÈ¡µÄ×Ö½ÚÊýÈ¥¸üÐÂÁ÷µÄ¶ÁдλÖᣠ</para> <methodsynopsis> <type>int</type><methodname>stream_write</methodname> <methodparam><type>string</type><parameter>data</parameter></methodparam> </methodsynopsis> <para> µ±¶ÔÁ÷½øÐÐ <function>fwrite</function> ²Ù×÷ʱ±¾·½·¨±»µ÷ÓᣱØÐ뽫 <parameter>data</parameter> ´¢´æµ½ÄãµÄÁ÷ʹÓÃµÄµ×²ã´æ´¢¿Õ¼äÈ¥¡£Èç¹ûûÓÐ×ã¹»µÄ¿Õ¼äÁË£¬ÔòÊÔ×ű£´æ¾¡¿ÉÄܶàµÄ×Ö½Ú¡£Ó¦¸Ã·µ»Ø³É¹¦±»±£´æÈëÁ÷µÄ×Ö½ÚÊý£¬»òÕßûÓб£´æÊ±·µ»Ø 0¡£±ØÐëÓóɹ¦Ð´ÈëµÄ×Ö½ÚÊýÈ¥¸üÐÂÁ÷µÄ¶ÁдλÖᣠ</para> <methodsynopsis> <type>boolean</type><methodname>stream_eof</methodname> <methodparam><type>void</type><parameter></parameter></methodparam> </methodsynopsis> <para> µ±¶ÔÁ÷½øÐÐ <function>feof</function> ²Ù×÷ʱ±¾·½·¨±»µ÷Óá£Èç¹û¶ÁдλÖõ½ÁËÁ÷µÄ¾¡Í·»òÕßûÓиü¶àÊý¾Ý¿É¶Áʱ·µ»Ø &true;£¬·ñÔò·µ»Ø &false;¡£ </para> <methodsynopsis> <type>int</type><methodname>stream_tell</methodname> <methodparam><type>void</type><parameter></parameter></methodparam> </methodsynopsis> <para> µ±¶ÔÁ÷½øÐÐ <function>ftell</function> ²Ù×÷ʱ±¾·½·¨±»µ÷Óá£Ó¦¸Ã·µ»ØÁ÷µÄµ±Ç°¶ÁдλÖᣠ</para> <methodsynopsis> <type>boolean</type><methodname>stream_seek</methodname> <methodparam><type>int</type><parameter>offset</parameter></methodparam> <methodparam><type>int</type><parameter>whence</parameter></methodparam> </methodsynopsis> <para> µ±¶ÔÁ÷½øÐÐ <function>fseek</function> ²Ù×÷ʱ±¾·½·¨±»µ÷Óá£Ó¦¸Ã¸ù¾Ý <parameter>offset</parameter> ºÍ <parameter>whence</parameter> À´¸üÐÂÁ÷µÄ¶ÁдλÖá£ÕâЩ²ÎÊýµÄ¸ü¶àÐÅÏ¢¼û <function>fseek</function>¡£Èç¹ûλÖóɹ¦¸üÐÂÁËÔò·µ»Ø &true;£¬·ñÔò·µ»Ø &false;¡£ </para> <methodsynopsis> <type>boolean</type><methodname>stream_flush</methodname> <methodparam><type>void</type><parameter></parameter></methodparam> </methodsynopsis> <para> µ±¶ÔÁ÷½øÐÐ <function>fflush</function> ²Ù×÷ʱ±¾·½·¨±»µ÷Óá£Èç¹ûÄãÔÚÁ÷Öлº´æÁËÊý¾Ý»¹Ã»ÓÐдÈëµ×²ã´æ´¢¿Õ¼äʱ£¬ÄÇÏÖÔÚÓ¦¸Ã×öÁË¡£Èç¹û»º´æÊý¾Ý±»³É¹¦±£´æ£¨»òûÓÐÊý¾Ý¿É¹©±£´æ£©Ê±·µ»Ø &true;£¬µ±Êý¾ÝÎÞ·¨±»±£´æÊ±·µ»Ø &false;¡£ </para> <para> ÏÂÃæµÄÀý×ÓʵÏÖÁËÒ»¸ö var:// ЭÒé´¦ÀíÆ÷£¬¿ÉÒÔÔÊÐíʹÓñê×¼µÄÎļþϵͳÁ÷º¯ÊýÀ´¶ÔÖ¸¶¨µÄÈ«¾Ö±äÁ¿½øÐжÁд²Ù×÷£¬ÀýÈç <function>fread</function>¡£var:// ЭÒéµÄʵÏÖÈçÏ£¬¸ø³ö url "var://foo" ½«¿ÉÒÔ¶Áд $GLOBALS["foo"]¡£ <example> <title>¶Áдȫ¾Ö±äÁ¿µÄÁ÷</title> <programlisting role="php"> <![CDATA[ class VariableStream { var $position; var $varname; function stream_open($path, $mode, $options, &$opened_path) { $url = parse_url($path); $this->varname = $url["host"]; $this->position = 0; return true; } function stream_read($count) { $ret = substr($GLOBALS[$this->varname], $this->position, $count); $this->position += strlen($ret); return $ret; } function stream_write($data) { $left = substr($GLOBALS[$this->varname], 0, $this->position); $right = substr($GLOBALS[$this->varname], $this->position + strlen($data)); $GLOBALS[$this->varname] = $left . $data . $right; $this->position += strlen($data); return strlen($data); } function stream_tell() { return $this->position; } function stream_eof() { return $this->position >= strlen($GLOBALS[$this->varname]); } function stream_seek($offset, $whence) { switch($whence) { case SEEK_SET: if ($offset < strlen($GLOBALS[$this->varname]) && $offset >= 0) { $this->position = $offset; return true; } else { return false; } break; case SEEK_CUR: if ($offset >= 0) { $this->position += $offset; return true; } else { return false; } break; case SEEK_END: if (strlen($GLOBALS[$this->varname]) + $offset >= 0) { $this->position = strlen($GLOBALS[$this->varname]) + $offset; return true; } else { return false; } break; default: return false; } } } stream_register_wrapper("var", "VariableStream") or die("Failed to register protocol"); $myvar = ""; $fp = fopen("var://myvar", "r+"); fwrite($fp, "line1\n"); fwrite($fp, "line2\n"); fwrite($fp, "line3\n"); rewind($fp); while(!feof($fp)) { echo fgets($fp) } fclose($fp); var_dump($myvar); ]]> </programlisting> </example> </para> </refsect1> </refentry> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> http://cvs.php.net/co.php/phpdoc-zh/reference/stream/functions/stream-wrapper-register.xml?r=1.1&p=1 Index: phpdoc-zh/reference/stream/functions/stream-wrapper-register.xml +++ phpdoc-zh/reference/stream/functions/stream-wrapper-register.xml <?xml version="1.0" encoding="gb2312"?> <!-- $Revision: 1.1 $ --> <!-- $Author: yincheng $ --> <!-- EN-Revision: 1.1 Maintainer: dallas Status: ready --> <refentry id="function.stream-register-wrapper"> <refnamediv> <refname>stream_register_wrapper</refname> <refpurpose>×¢²áÒ»¸öÓà PHP ÀàʵÏÖµÄ URL ·âװЭÒé</refpurpose> </refnamediv> <refsect1> <title>˵Ã÷</title> <methodsynopsis> <type>boolean</type><methodname>stream_register_wrapper</methodname> <methodparam><type>string</type><parameter>protocol</parameter></methodparam> <methodparam><type>string</type><parameter>classname</parameter></methodparam> </methodsynopsis> <para> <function>stream_register_wrapper</function> ÔÊÐíÓû§ÊµÏÖ×Ô¶¨ÒåµÄЭÒé´¦ÀíÆ÷ºÍÁ÷£¬ÓÃÓÚËùÓÐÆäËüµÄÎļþϵͳº¯ÊýÖУ¨ÀýÈç <function>fopen</function>£¬<function>fread</function> µÈ£©¡£ </para> <para> ҪʵÏÖÒ»¸ö·âװЭÒ飬ÐèÒª°´ÕÕÈç϶¨ÒåÉùÃ÷Ò»¸ö°üº¬ÓÐһЩº¯ÊýµÄÀà¡£µ±ÓÐÈ˶ÔÄãµÄÁ÷ʹÓà fopen ʱ£¬PHP ½«´´½¨Ò»¸ö <parameter>classname</parameter> µÄʵÀý²¢µ÷ÓøÃʵÀýµÄ·½·¨¡£±ØÐëÑϸñ°´ÕÕÈçϵÄÃèÊöʵÏÖ·½·¨ - ·ñÔò½«µ¼Ö²»Ã÷È·µÄÐÐΪ¡£ </para> <para> Èç¹û <parameter>protocol</parameter> ÒѾ­ÓÐÁË´¦ÀíЭÒ飬Ôò <function>stream_register_wrapper</function> ½«·µ»Ø &false;¡£ </para> <methodsynopsis> <type>boolean</type><methodname>stream_open</methodname> <methodparam><type>string</type><parameter>path</parameter></methodparam> <methodparam><type>string</type><parameter>mode</parameter></methodparam> <methodparam><type>int</type><parameter>options</parameter></methodparam> <methodparam><type>string</type><parameter>opened_path</parameter></methodparam> </methodsynopsis> <para> µ±ÄãµÄÁ÷¶ÔÏó±»´´½¨Ö®ºóÁ¢¼´»áµ÷Óô˷½·¨¡£<parameter>path</parameter> Ö¸¶¨ÁË´«Èë <function>fopen</function> ÒÔ¼°´Ë¶ÔÏóÐèҪȡ»ØµÄ URL¡£¿ÉÒÔÓà <function>parse_url</function> À´½«´Ë URL ·Ö¸î³É¼¸²¿·Ö¡£ </para> <para> <parameter>mode</parameter> ÓÃÀ´´ò¿ªÎļþµÄģʽ£¬ºÍ <function>fopen</function> ÖеÄÒ»Ñù¡£ÄãÓÐÔðÈμì²é <parameter>mode</parameter> ¶ÔÓÚËùÇëÇóµÄ <parameter>path</parameter> ÊÇ·ñºÏ·¨¡£ </para> <para> <parameter>options</parameter> ±£´æÁËͨ¹ýÁ÷ API É趨µÄ¸½¼Ó±êÖ¾¡£¿ÉÒÔ±£´æÒÔÏÂÒ»¸öÖµ»òÕßÓà OR ºÏ²¢µÄ¶à¸öÖµ¡£ <informaltable> <tgroup cols="2"> <thead> <row> <entry>±êÖ¾</entry> <entry>˵Ã÷</entry> </row> </thead> <tbody> <row> <entry>STREAM_USE_PATH</entry> <entry>Èç¹û <parameter>path</parameter> ÊÇÏà¶Ô·¾¶£¬ÔòÓà include_path ËÑË÷×ÊÔ´¡£ </entry> </row> <row> <entry>STREAM_REPORT_ERRORS</entry> <entry>Èç¹ûÉ趨Á˱¾±êÖ¾£¬ÄãÓÐÔðÈÎÔÚ´ò¿ªÁ÷ʱÓà <function>trigger_error</function> À´»½Æð´íÎó¡£Èç¹ûûÓÐÉ趨Õâ¸ö±êÖ¾£¬ÄÇôÄã²»ÐèÒª»½ÆðÈκδíÎó¡£ </entry> </row> </tbody> </tgroup> </informaltable> </para> <para> Èç¹û³É¹¦´ò¿ªÁË <parameter>path</parameter>£¬²¢ÇÒÔÚ <parameter>options</parameter> ÖÐÉ趨ÁË STREAM_USE_PATH£¬ÄãÐèÒª½« <parameter>opened_path</parameter> É趨Ϊʵ¼Ê±»´ò¿ªµÄÎļþ£¯×ÊÔ´µÄÍêÕû·¾¶¡£ </para> <para> Èç¹û³É¹¦´ò¿ªÁËËùÇëÇóµÄ×ÊÔ´£¬Ó¦¸Ã·µ»Ø &true;£¬·ñÔò·µ»Ø &false;¡£ </para> <methodsynopsis> <type>void</type><methodname>stream_close</methodname> <methodparam><type>void</type><parameter></parameter></methodparam> </methodsynopsis> <para> ±¾·½·¨ÔÚÁ÷¹Ø±Õʱ±»µ÷Óã¬Ê¹Óà <function>fclose</function>¡£±ØÐëÊͷű»Á÷Ëø¶¨»ò·ÖÅäµÄÈκÎ×ÊÔ´¡£ </para> <methodsynopsis> <type>string</type><methodname>stream_read</methodname> <methodparam><type>int</type><parameter>count</parameter></methodparam> </methodsynopsis> <para> µ±¶ÔÁ÷½øÐÐ <function>fread</function> ºÍ <function>fgets</function> ²Ù×÷ʱ±¾·½·¨±»µ÷ÓᣱØÐë´Óµ±Ç°¶ÁдλÖÃÒÔ×Ö·û´®·µ»Ø×î¶à <parameter>count</parameter> ×Ö½ÚµÄÊý¾Ý¡£Èç¹û¿ÉÓÃÊý¾ÝÉÙÓÚ <parameter>count</parameter> ×Ö½Ú£¬Ôò·µ»Ø¾¡¿ÉÄܶàµÄÊý¾Ý¡£Èç¹ûûÓпɹ©·µ»ØµÄÊý¾Ý£¬·µ»Ø &false; »òÕß¿Õ×Ö·û´®¡£±ØÐëÓóɹ¦¶ÁÈ¡µÄ×Ö½ÚÊýÈ¥¸üÐÂÁ÷µÄ¶ÁдλÖᣠ</para> <methodsynopsis> <type>int</type><methodname>stream_write</methodname> <methodparam><type>string</type><parameter>data</parameter></methodparam> </methodsynopsis> <para> µ±¶ÔÁ÷½øÐÐ <function>fwrite</function> ²Ù×÷ʱ±¾·½·¨±»µ÷ÓᣱØÐ뽫 <parameter>data</parameter> ´¢´æµ½ÄãµÄÁ÷ʹÓÃµÄµ×²ã´æ´¢¿Õ¼äÈ¥¡£Èç¹ûûÓÐ×ã¹»µÄ¿Õ¼äÁË£¬ÔòÊÔ×ű£´æ¾¡¿ÉÄܶàµÄ×Ö½Ú¡£Ó¦¸Ã·µ»Ø³É¹¦±»±£´æÈëÁ÷µÄ×Ö½ÚÊý£¬»òÕßûÓб£´æÊ±·µ»Ø 0¡£±ØÐëÓóɹ¦Ð´ÈëµÄ×Ö½ÚÊýÈ¥¸üÐÂÁ÷µÄ¶ÁдλÖᣠ</para> <methodsynopsis> <type>boolean</type><methodname>stream_eof</methodname> <methodparam><type>void</type><parameter></parameter></methodparam> </methodsynopsis> <para> µ±¶ÔÁ÷½øÐÐ <function>feof</function> ²Ù×÷ʱ±¾·½·¨±»µ÷Óá£Èç¹û¶ÁдλÖõ½ÁËÁ÷µÄ¾¡Í·»òÕßûÓиü¶àÊý¾Ý¿É¶Áʱ·µ»Ø &true;£¬·ñÔò·µ»Ø &false;¡£ </para> <methodsynopsis> <type>int</type><methodname>stream_tell</methodname> <methodparam><type>void</type><parameter></parameter></methodparam> </methodsynopsis> <para> µ±¶ÔÁ÷½øÐÐ <function>ftell</function> ²Ù×÷ʱ±¾·½·¨±»µ÷Óá£Ó¦¸Ã·µ»ØÁ÷µÄµ±Ç°¶ÁдλÖᣠ</para> <methodsynopsis> <type>boolean</type><methodname>stream_seek</methodname> <methodparam><type>int</type><parameter>offset</parameter></methodparam> <methodparam><type>int</type><parameter>whence</parameter></methodparam> </methodsynopsis> <para> µ±¶ÔÁ÷½øÐÐ <function>fseek</function> ²Ù×÷ʱ±¾·½·¨±»µ÷Óá£Ó¦¸Ã¸ù¾Ý <parameter>offset</parameter> ºÍ <parameter>whence</parameter> À´¸üÐÂÁ÷µÄ¶ÁдλÖá£ÕâЩ²ÎÊýµÄ¸ü¶àÐÅÏ¢¼û <function>fseek</function>¡£Èç¹ûλÖóɹ¦¸üÐÂÁËÔò·µ»Ø &true;£¬·ñÔò·µ»Ø &false;¡£ </para> <methodsynopsis> <type>boolean</type><methodname>stream_flush</methodname> <methodparam><type>void</type><parameter></parameter></methodparam> </methodsynopsis> <para> µ±¶ÔÁ÷½øÐÐ <function>fflush</function> ²Ù×÷ʱ±¾·½·¨±»µ÷Óá£Èç¹ûÄãÔÚÁ÷Öлº´æÁËÊý¾Ý»¹Ã»ÓÐдÈëµ×²ã´æ´¢¿Õ¼äʱ£¬ÄÇÏÖÔÚÓ¦¸Ã×öÁË¡£Èç¹û»º´æÊý¾Ý±»³É¹¦±£´æ£¨»òûÓÐÊý¾Ý¿É¹©±£´æ£©Ê±·µ»Ø &true;£¬µ±Êý¾ÝÎÞ·¨±»±£´æÊ±·µ»Ø &false;¡£ </para> <para> ÏÂÃæµÄÀý×ÓʵÏÖÁËÒ»¸ö var:// ЭÒé´¦ÀíÆ÷£¬¿ÉÒÔÔÊÐíʹÓñê×¼µÄÎļþϵͳÁ÷º¯ÊýÀ´¶ÔÖ¸¶¨µÄÈ«¾Ö±äÁ¿½øÐжÁд²Ù×÷£¬ÀýÈç <function>fread</function>¡£var:// ЭÒéµÄʵÏÖÈçÏ£¬¸ø³ö url "var://foo" ½«¿ÉÒÔ¶Áд $GLOBALS["foo"]¡£ <example> <title>¶Áдȫ¾Ö±äÁ¿µÄÁ÷</title> <programlisting role="php"> <![CDATA[ class VariableStream { var $position; var $varname; function stream_open($path, $mode, $options, &$opened_path) { $url = parse_url($path); $this->varname = $url["host"]; $this->position = 0; return true; } function stream_read($count) { $ret = substr($GLOBALS[$this->varname], $this->position, $count); $this->position += strlen($ret); return $ret; } function stream_write($data) { $left = substr($GLOBALS[$this->varname], 0, $this->position); $right = substr($GLOBALS[$this->varname], $this->position + strlen($data)); $GLOBALS[$this->varname] = $left . $data . $right; $this->position += strlen($data); return strlen($data); } function stream_tell() { return $this->position; } function stream_eof() { return $this->position >= strlen($GLOBALS[$this->varname]); } function stream_seek($offset, $whence) { switch($whence) { case SEEK_SET: if ($offset < strlen($GLOBALS[$this->varname]) && $offset >= 0) { $this->position = $offset; return true; } else { return false; } break; case SEEK_CUR: if ($offset >= 0) { $this->position += $offset; return true; } else { return false; } break; case SEEK_END: if (strlen($GLOBALS[$this->varname]) + $offset >= 0) { $this->position = strlen($GLOBALS[$this->varname]) + $offset; return true; } else { return false; } break; default: return false; } } } stream_register_wrapper("var", "VariableStream") or die("Failed to register protocol"); $myvar = ""; $fp = fopen("var://myvar", "r+"); fwrite($fp, "line1\n"); fwrite($fp, "line2\n"); fwrite($fp, "line3\n"); rewind($fp); while(!feof($fp)) { echo fgets($fp) } fclose($fp); var_dump($myvar); ]]> </programlisting> </example> </para> </refsect1> </refentry> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 -->
« previous php.doc.zh (#2010) next »