Re: phpdoc-zh /reference/var/functions unset.xml
| From: | Krazy Nio | Date: | Mon, 16 Jun 2003 01:24:49 +0000 |
| Subject: | Re: phpdoc-zh /reference/var/functions unset.xml | ||
| References: | 1 2 | Groups: | php.doc.zh |
| Request: | Send a blank email to doc-zh+get-1513@lists.php.net to get a copy of this message | ||
我也是觉得有些生硬,但是翻了好多资料,没找到合适的,本来想用“释放”或者
“清除”的,后来觉得也有些别扭,不知道 Dallas
有没有更好的词可用。。。
Dallas Thunder wrote:
> “破坏”似乎太生硬了些吧
>
> "Krazy Nio" <nio@php.net> 写入邮件
> news:cvsnio1055599900@cvsserver...
>
>>nio Sat Jun 14 10:11:40 2003 EDT
>>
>> Added files:
>> /phpdoc-zh/reference/var/functions unset.xml
>> Log:
>> Add file
>>
>>
>>Index: phpdoc-zh/reference/var/functions/unset.xml
>>+++ phpdoc-zh/reference/var/functions/unset.xml
>><?xml version="1.0" encoding="gb2312"?>
>><!-- $Revision: 1.1 $ -->
>><!-- $Author: nio $ -->
>><!-- EN-Revision: 1.2 Maintainer: nio Status: ready -->
>><!-- splitted from ./en/functions/var.xml, last change in rev 1.2 -->
>> <refentry id="function.unset">
>> <refnamediv>
>> <refname>unset</refname>
>> <refpurpose>释放给定的变量</refpurpose>
>> </refnamediv>
>> <refsect1>
>> <title>描述</title>
>> <methodsynopsis>
>> <type>void</type><methodname>unset</methodname>
>>
>
> <methodparam><type>mixed</type><parameter>var</parameter></methodparam>
>
>> <methodparam
>
>
> choice="opt"><type>mixed</type><parameter>var</parameter></methodparam>
>
>> <methodparam
>> choice="opt"><parameter>...</parameter></methodparam>
>> </methodsynopsis>
>> <note>
>> <para>
>> <function>unset</function> 是语言结构的一部分。
>> </para>
>> </note>
>> <para>
>> <function>unset</function> 破坏指定的变量。注意在
>> PHP 3 中,<function>unset</function> 将返回
>> &true;(实际上是整型值 1),而在 PHP 4
>> 中,<function>unset</function>
>>
>> 不再是一个真正的函数:它现在是一个语句。这样就没有了返回值,试图获取
>> <function>unset</function> 的返回值将导致解析错误。
>> </para>
>> <para>
>> <example>
>> <title><function>unset</function> 示例</title>
>> <programlisting role="php">
>><![CDATA[
>>// 破坏单个变量
>>unset ($foo);
>>
>>// 破坏单个数组元素
>>unset ($bar['quux']);
>>
>>// 破坏一个以上的变量
>>unset ($foo1, $foo2, $foo3);
>>]]>
>> </programlisting>
>> </example>
>> </para>
>> <para>
>> <function>unset</function>
>> 在函数中的行为会依赖于想要破坏的变量的类型
>
> 而有所不同。
>
>> </para>
>> <para>
>> 如果在函数中 <function>unset</function>
>>
>> 一个全局变量,则只是局部变量被破坏,而在调用环境中的变量将保持调用
>> <function>unset</function> 之前一样的值。
>> <informalexample>
>> <programlisting role="php">
>><![CDATA[
>>function destroy_foo() {
>> global $foo;
>> unset($foo);
>>}
>>
>>$foo = 'bar';
>>destroy_foo();
>>echo $foo;
>>]]>
>> </programlisting>
>> </informalexample>
>> 上边的例子将输出:
>> <informalexample>
>> <screen>
>><![CDATA[
>>bar
>>]]>
>> </screen>
>> </informalexample>
>> </para>
>> <para>
>> 如果在函数中 <function>unset</function>
>>
>> 一个通过引用传递的变量,则只是局部变量被破坏,而在调用环境中的变量将
>
> 保持调用
>
>> <function>unset</function> 之前一样的值。
>> <informalexample>
>> <programlisting role="php">
>><![CDATA[
>>function foo(&$bar) {
>> unset($bar);
>> $bar = "blah";
>>}
>>
>>$bar = 'something';
>>echo "$bar\n";
>>
>>foo($bar);
>>echo "$bar\n";
>>]]>
>> </programlisting>
>> </informalexample>
>> 上边的例子将输出:
>> <informalexample>
>> <screen>
>><![CDATA[
>>something
>>something
>>]]>
>> </screen>
>> </informalexample>
>> </para>
>> <para>
>> 如果在函数中 <function>unset</function>
>> 一个静态变量,则 <function>unset</function>
>> 将破坏此变量及其所有的引用。
>> <informalexample>
>> <programlisting role="php">
>><![CDATA[
>>function foo() {
>> static $a;
>> $a++;
>> echo "$a\n";
>> unset($a);
>>}
>>
>>foo();
>>foo();
>>foo();
>>]]>
>> </programlisting>
>> </informalexample>
>> 上边的例子将输出:
>> <informalexample>
>> <screen>
>><![CDATA[
>>1
>>2
>>3
>>]]>
>> </screen>
>> </informalexample>
>> </para>
>> <para>
>> 如果您想在函数中 <function>unset</function>
>> 一个全局变量,可使用 <varname>$GLOBALS</varname>
>> 数组来实现:
>> <informalexample>
>> <programlisting role="php">
>><![CDATA[
>>function foo() {
>> unset($GLOBALS['bar']);
>>}
>>
>>$bar = "something";
>>foo();
>>]]>
>> </programlisting>
>> </informalexample>
>> </para>
>> <para>
>> 参见 <function>isset</function> 和
>> <function>empty</function>。
>> </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
>>-->
>>
>>
>