Skip to content

Commit

Permalink
Sync filesystem functions and language (php#906)
Browse files Browse the repository at this point in the history
  • Loading branch information
sy-records authored Sep 4, 2024
1 parent 050bdf5 commit 0b6c17c
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 37 deletions.
6 changes: 3 additions & 3 deletions language/context/ftp.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: bad50150f7e06228f48c4461fab52afe08a4d5e4 Maintainer: Jader Status: ready -->
<!-- CREDITS: mowangjuanzi -->
<!-- EN-Revision: 099db652feea008bbb83805f90b8717966357f7c Maintainer: Jader Status: ready -->
<!-- CREDITS: mowangjuanzi, Luffy -->
<refentry xml:id="context.ftp" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" annotations="verify_info:false" role="stream_context_option">
<refnamediv>
<refname>FTP 上下文选项</refname>
Expand Down Expand Up @@ -67,7 +67,7 @@
<note>
<title>底层套接字流上下文选项</title>
<simpara>
<link linkend="transports.inet">底层传输</link> 可能支持其他上下文选项
<link linkend="transports.inet">底层传输</link> 可能支持其他上下文选项
对于 <literal>ftp://</literal> 流,请参阅 <literal>tcp://</literal> 传输的上下文选项。
对于 <literal>ftps://</literal> 流,请参阅 <literal>ssl://</literal> 传输的上下文选项。
</simpara>
Expand Down
15 changes: 7 additions & 8 deletions language/context/http.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: bad50150f7e06228f48c4461fab52afe08a4d5e4 Maintainer: z warmwinter Status: ready -->
<!-- CREDITS: Jader, mowangjuanzi -->

<!-- EN-Revision: 5c2a2c955824a523ca93530aab13eeaf0e45900e Maintainer: z warmwinter Status: ready -->
<!-- CREDITS: Jader, mowangjuanzi, Luffy -->
<refentry xml:id="context.http" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" annotations="verify_info:false" role="stream_context_option">
<refnamediv>
<refname>HTTP context 选项</refname>
Expand Down Expand Up @@ -84,8 +83,8 @@
</term>
<listitem>
<para>
URI 指定的代理服务器的地址。(e.g.
<literal>tcp://proxy.example.com:5100</literal>).
URI 指定的代理服务器的地址(例如:
<literal>tcp://proxy.example.com:5100</literal>)。
</para>
</listitem>
</varlistentry>
Expand All @@ -96,8 +95,8 @@
</term>
<listitem>
<para>
当设置为 &true; 时,在构建请求时将使用整个 URI 。(例如:
<literal>GET http://www.example.com/path/to/file.html HTTP/1.0</literal>)
当设置为 &true; 时,在构建请求时将使用整个 URI例如:
<literal>GET http://www.example.com/path/to/file.html HTTP/1.0</literal>
虽然这是一个非标准的请求格式,但某些代理服务器需要它。
</para>
<para>
Expand Down Expand Up @@ -154,7 +153,7 @@
</term>
<listitem>
<para>
读取超时时间,单位为秒(s),用 <type>float</type> 指定(e.g. <literal>10.5</literal>)
读取超时时间,单位为秒(s),用 <type>float</type> 指定(例如:<literal>10.5</literal>
</para>
<para>
默认使用 &php.ini; 中设置的 <link linkend="ini.default-socket-timeout">default_socket_timeout</link>。
Expand Down
12 changes: 9 additions & 3 deletions language/predefined/weakmap/offsetget.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: d27fdfe8f990c14955354176a615e6e8daeb0525 Maintainer: mowangjuanzi Status: ready -->
<!-- EN-Revision: d53be0b46d1cd1d69ff07f7960ef4a5d12d82f7f Maintainer: mowangjuanzi Status: ready -->
<!-- CREDITS: Luffy -->
<refentry xml:id="weakmap.offsetget" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>WeakMap::offsetGet</refname>
Expand Down Expand Up @@ -35,11 +36,16 @@
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
返回与作为参数传入对象关联的值,
否则返回 &null;
返回与作为参数传入对象关联的值。
</para>
</refsect1>

<refsect1 role="errors"><!-- {{{ -->
&reftitle.errors;
<para>
失败时抛出一个 <classname>Error</classname> 异常。
</para>
</refsect1>

</refentry>
<!-- Keep this comment at the end of the file
Expand Down
9 changes: 5 additions & 4 deletions language/types/declarations.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: f94d903985119d3ac00f4528551df947f57b667f Maintainer: avenger Status: ready -->
<!-- EN-Revision: 13273912b0f773c35f05297a47daa7f76dd52669 Maintainer: avenger Status: ready -->
<!-- CREDITS: mowangjuanzi, Luffy -->
<sect1 xml:id="language.types.declarations">
<title>类型声明</title>

<para>
类型声明可以用于函数的参数、返回值,PHP 7.4.0
起还可以用于类的属性,来显性的指定需要的类型,如果预期类型在调用时不匹配,则会抛出一个
<classname>TypeError</classname> 异常。
类型声明可以用于函数的参数、返回值,
PHP 7.4.0 起还可以用于类的属性,
PHP 8.3.0 起还可以用于类的常量。
如果预期类型在调用时不匹配,则会抛出一个 <classname>TypeError</classname> 异常。
</para>

<para>
Expand Down
11 changes: 8 additions & 3 deletions reference/filesystem/functions/fgets.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: ea62fb83196997032641b50fe44420305466195e Maintainer: HonestQiao Status: ready -->
<!-- CREDITS: mowangjuanzi -->
<!-- EN-Revision: 32e694be42ba6e75a8c78483c17a75725937d247 Maintainer: HonestQiao Status: ready -->
<!-- CREDITS: mowangjuanzi, Luffy -->
<refentry xml:id="function.fgets" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>fgets</refname>
Expand Down Expand Up @@ -64,16 +64,21 @@
<programlisting role="php">
<![CDATA[
<?php
$fp = @fopen("/tmp/inputfile.txt", "r");
if ($fp) {
while (($buffer = fgets($fp, 4096)) !== false) {
echo $buffer;
echo $buffer, PHP_EOL;
}
if (!feof($fp)) {
echo "Error: unexpected fgets() fail\n";
}
fclose($fp);
}
?>
]]>
</programlisting>
Expand Down
8 changes: 4 additions & 4 deletions reference/filesystem/functions/fopen.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: ea62fb83196997032641b50fe44420305466195e Maintainer: HonestQiao Status: ready -->
<!-- CREDITS: lm92, mowangjuanzi -->
<!-- EN-Revision: 74b2af242f2131cd43a8830fee3864f1f68ccbed Maintainer: HonestQiao Status: ready -->
<!-- CREDITS: lm92, mowangjuanzi, Luffy -->
<refentry xml:id="function.fopen" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>fopen</refname>
Expand Down Expand Up @@ -54,7 +54,7 @@
指定的是一个已注册的协议,而该协议被注册为一个网络
URL,PHP 将检查并确认
<link linkend="ini.allow-url-fopen">allow_url_fopen</link>
已被激活。如果关闭了,PHP 将发出一个警告,而 fopen 的调用则失败。
已被激活。如果关闭了,PHP 将发出一个警告,而 <function>fopen</function> 的调用则失败。
</para>
<note>
<para>
Expand Down Expand Up @@ -240,7 +240,7 @@ $handle = fopen("c:\\folder\\resource.txt", "r");
<link linkend="ini.include-path">include_path</link>
中搜寻文件的话,可以将可选的第三个参数
<parameter>use_include_path</parameter>
设为 '1' 或 &true;
设为 &true;
</para>
</listitem>
</varlistentry>
Expand Down
33 changes: 21 additions & 12 deletions reference/info/functions/ini-get.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: a0ae28d3bc85f927c22649ebd9a590b921534b7d Maintainer: daijie Status: ready -->
<!-- CREDITS: mowangjuanzi -->
<!-- EN-Revision: c8a8981a9df9a1564a4b9a79e84583d41a7b6ac5 Maintainer: daijie Status: ready -->
<!-- CREDITS: mowangjuanzi, Luffy -->
<refentry xml:id="function.ini-get" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>ini_get</refname>
Expand Down Expand Up @@ -50,6 +50,7 @@
<programlisting role="php">
<![CDATA[
<?php
/*
我们的 php.ini 包含了以下的设置:
Expand All @@ -59,25 +60,31 @@ post_max_size = 8M
*/
echo 'display_errors = ' . ini_get('display_errors') . "\n";
echo 'register_globals = ' . ini_get('register_globals') . "\n";
echo 'register_globals = ' . (int) ini_get('register_globals') . "\n";
echo 'post_max_size = ' . ini_get('post_max_size') . "\n";
echo 'post_max_size+1 = ' . (ini_get('post_max_size')+1) . "\n";
echo 'post_max_size + 1 = ' . (rtrim(ini_get('post_max_size'), 'KMG') + 1) . "\n";
echo 'post_max_size in bytes = ' . return_bytes(ini_get('post_max_size'));
function return_bytes($val) {
function return_bytes($val)
{
$val = trim($val);
$last = strtolower($val[strlen($val)-1]);
switch($last) {
$num = (int) rtrim($val, 'KMG');
$last = strtolower($val[strlen($val) - 1]);
switch ($last) {
// 可以使用修饰符 'G'
case 'g':
$val *= 1024;
$num = $num * 1024 * 1024 * 1024;
break;
case 'm':
$val *= 1024;
$num = $num * 1024 * 1024;
break;
case 'k':
$val *= 1024;
$num *= 1024;
break;
}
return $val;
return $num;
}
?>
Expand Down Expand Up @@ -119,7 +126,9 @@ post_max_size in bytes = 8388608
</note>
<note>
<para>
<function>ini_get</function> 无法读取 "array" 的 ini 选项,例如 pdo.dsn.*,在这个示例中会返回 &false;
<function>ini_get</function> 无法读取 "array" 的 ini 选项,
例如 <literal>pdo.dsn.<replaceable>*</replaceable></literal>,
在这个示例中会返回 &false;
</para>
</note>
</refsect1>
Expand Down

0 comments on commit 0b6c17c

Please sign in to comment.