kevinkee Sat Jun 7 13:27:52 2003 EDT
Modified files:
/phpdoc/en/language variables.xml
Log:
new file
Index: phpdoc/en/language/variables.xml
diff -u phpdoc/en/language/variables.xml:1.59 phpdoc/en/language/variables.xml:1.60
--- phpdoc/en/language/variables.xml:1.59 Fri Jun 6 01:33:09 2003
+++ phpdoc/en/language/variables.xml Sat Jun 7 13:27:52 2003
@@ -1,28 +1,22 @@
-<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.59 $ -->
+<?xml version="1.0" encoding="big5"?>
+<!-- $Revision: 1.60 $ -->
<chapter id="language.variables">
- <title>Variables</title>
+ <title>�U���ܼ�</title>
<sect1 id="language.variables.basics">
- <title>Basics</title>
+ <title>����</title>
<simpara>
- Variables in PHP are represented by a dollar sign followed by the
- name of the variable. The variable name is case-sensitive.
+ �Ҧ� PHP ���ܼƳ��O�H "$" ���}�ݡA��[�ܼƦW�Ҳզ����C�ܼƦW�٬O���j�p�g�������C
</simpara>
<para>
- Variable names follow the same rules as other labels in PHP. A
- valid variable name starts with a letter or underscore, followed
- by any number of letters, numbers, or underscores. As a regular
- expression, it would be expressed thus:
- '[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*'
+ PHP [EMAIL PROTECTED]'[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*'
</para>
<note>
<simpara>
- For our purposes here, a letter is a-z, A-Z, and the ASCII
- characters from 127 through 255 (0x7f-0xff).
+ �r���� a-z�AA-Z�A�� ASCII �r�ūh�q 127 �� 255�q0x7f-0xff�r�C
</simpara>
</note>
@@ -45,33 +39,14 @@
</para>
<para>
- In PHP 3, variables are always assigned by value. That is to say,
- when you assign an expression to a variable, the entire value of
- the original expression is copied into the destination
- variable. This means, for instance, that after assigning one
- variable's value to another, changing one of those variables will
- have no effect on the other. For more information on this kind of
- assignment, see the chapter on <link
- linkend="language.expressions">Expressions</link>.
+ PHP 3 [EMAIL PROTECTED]@���ܼƮɡA��ӭ�l�B�⦡���ȱN�|[EMAIL PROTECTED]@[EMAIL
PROTECTED]|[EMAIL PROTECTED]<link linkend="language.expressions">�B�⦡</link>[EMAIL
PROTECTED]
</para>
<para>
- PHP 4 offers another way to assign values to variables:
- <link linkend="language.references">assign by reference</link>.
- This means that the new variable simply references (in other words,
- "becomes an alias for" or "points to") the original variable.
- Changes to the new variable affect the original, and vice versa.
- This also means that no copying is performed; thus, the assignment
- happens more quickly. However, any speedup will likely be noticed
- only in tight loops or when assigning large
- <link linkend="language.types.array">arrays</link> or
- <link linkend="language.types.object">objects</link>.
+ PHP 4 [EMAIL PROTECTED]<link linkend="language.references">�ǧ}����</link>[EMAIL
PROTECTED]|[EMAIL PROTECTED]@[EMAIL PROTECTED]<link
linkend="language.types.array">�}�C</link>��<link
linkend="language.types.object">����</link>�ɤ~�|��ı�t�ת����ɡC
</para>
<para>
- To assign by reference, simply prepend an ampersand (&) to the
- beginning of the variable which is being assigned (the source
- variable). For instance, the following code snippet outputs 'My
- name is Bob' twice:
-
+ [EMAIL PROTECTED] (&) ���Ÿ��C�Ҧp�A�U�C�{���X�b�ϥζǧ}�������X 'My name
is Bob' �⦸�C
+
<informalexample>
<programlisting role="php">
<![CDATA[
@@ -88,8 +63,7 @@
</para>
<para>
- One important thing to note is that only named variables may be
- assigned by reference.
+ �ݭn�`�N���O�u���u���R�W���ܼƤ~�i�H�ΨӶi��ǧ}�����C
<informalexample>
<programlisting role="php">
<![CDATA[
@@ -112,89 +86,48 @@
</sect1>
<sect1 id="language.variables.predefined">
- <title>Predefined variables</title>
+ <title>�w�]���ܼ�</title>
<simpara>
- PHP provides a large number of predefined variables to any script
- which it runs. Many of these variables, however, cannot be fully
- documented as they are dependent upon which server is running, the
- version and setup of the server, and other factors. Some of these
- variables will not be available when PHP is run on the
- <link linkend="features.commandline">command line</link>.
- For a listing of these variables, please see the section on
- <link linkend="reserved.variables">Reserved Predefined Variables</link>.
+ PHP [EMAIL PROTECTED]<link
linkend="features.commandline">���O��</link>���Ҧ��B��ɬO����ϥΪ��C�����o���ܼƪ��C���A�аѦ�<link
linkend="reserved.variables">�O�d�����e�w�q�ܼ�</link>[EMAIL PROTECTED]
</simpara>
<warning>
<simpara>
- In PHP 4.2.0 and later, the default value for the PHP directive <link
- linkend="ini.register-globals">register_globals</link> is
- <emphasis>off</emphasis>. This is a major change in PHP. Having
- register_globals <emphasis>off</emphasis> affects the set of predefined
- variables available in the global scope. For example, to get
- <varname>DOCUMENT_ROOT</varname> you'll use
- <varname>$_SERVER['DOCUMENT_ROOT']</varname> instead of
- <varname>$DOCUMENT_ROOT</varname>, or <varname>$_GET['id']</varname> from
- the URL <literal>http://www.example.com/test.php?id=3</literal> instead
- of <varname>$id</varname>, or <varname>$_ENV['HOME']</varname> instead of
- <varname>$HOME</varname>.
+ PHP 4.2.0 �H�᪺�����A<link
linkend="ini.register-globals">register_globals</link> ���O���w�]�ȬO
<emphasis>off</emphasis>[EMAIL PROTECTED] register_globals ���ȹw�]��
<emphasis>off</emphasis> �|�v�T��w�]�ܼƦb����d�����ĩʡC�Ҧp�A�n�o��
<varname>DOCUMENT_ROOT</varname> ���ȡA���ϥ�
<varname>$_SERVER['DOCUMENT_ROOT']</varname> �Ӥ��O
<varname>$DOCUMENT_ROOT</varname>�B�ϥ� <varname>$_GET['id']</varname> �H���o URL
<literal>http://www.example.com/test.php?id=3</literal> �� id ���ȡA�Ӥ��O��
<varname>$id</varname>�B�Ψϥ� <varname>$_ENV['HOME']</varname> �Ө��N
<varname>$HOME</varname>�C
</simpara>
<simpara>
- For related information on this change, read the configuration entry for
- <link linkend="ini.register-globals">register_globals</link>, the security
- chapter on <link linkend="security.registerglobals">Using Register Globals
- </link>, as well as the PHP <ulink url="&url.php.release4.1.0;">4.1.0
- </ulink> and <ulink url="&url.php.release4.2.0;">4.2.0</ulink> Release
- Announcements.
+ ��h�P������������ƥi�b <link
linkend="ini.register-globals">register_globals</link> [EMAIL PROTECTED]<link
linkend="security.registerglobals">�ϥ� Register Globals</link> �����w�����A�Φb
<ulink url="&url.php.release4.1.0;">4.1.0</ulink> �� <ulink
url="&url.php.release4.2.0;">4.2.0</ulink> ���o��q�i�����o�C
</simpara>
<simpara>
- Using the available PHP Reserved Predefined Variables, like the
- <link linkend="language.variables.superglobals">superglobal arrays</link>,
- is preferred.
+ �ڭ̫�ij�z�ϥ� PHP ���Ѫ��O�d�w�]�ܼơA�p <link
linkend="language.variables.superglobals">superglobal ���C</link>�C
</simpara>
</warning>
<simpara>
- From version 4.1.0 onward, PHP provides an additional set of predefined arrays
- containing variables from the web server (if applicable), the
- environment, and user input. These new arrays are rather special
- in that they are automatically global--i.e., automatically
- available in every scope. For this reason, they are often known as
- 'autoglobals' or 'superglobals'. (There is no mechanism in PHP for
- user-defined superglobals.) The superglobals are listed below;
- however, for a listing of their contents and further discussion on
- PHP predefined variables and their natures, please see the section
- <link linkend="reserved.variables">Reserved Predefined Variables</link>.
- Also, you'll notice how the older predefined variables
- (<varname>$HTTP_*_VARS</varname>) still exist.
-
+ �� 4.1.0 �����_�APHP [EMAIL
PROTECTED]|�۰ʦa�]������A�Y�i�H�b�Ҧ��d�ϥΡC���]�p���A���̤]�Q�٬�
'autoglobals' �� 'superglobals'�C�qPHP �|�����ϥΪ̦ۦ�w�q superglobals
���\��C�r�ڭ̱N�b�U���C�X superglobals�A���n���D���̪����e�M PHP
�w�]�ܼƪ��`�J�Q�סA�аѦ�<link
linkend="reserved.variables">�O�d�����e�w�q�ܼ�</link>[EMAIL
PROTECTED]|�d�N�¦����w�]�ܼ� (<varname>$HTTP_*_VARS</varname>) ���M�s�b�C
+
&avail.register-long-arrays;
</simpara>
<note>
- <title>Variable variables</title>
+ <title>�i���ܼ�</title>
<para>
- Superglobals cannot be used as
- <link linkend="language.variables.variable">variable variables</link>.
+ Superglobals ������@<link
linkend="language.variables.variable">�i���ܼ�</link>�ӨϥΡC
</para>
</note>
<para>
- If certain variables in <link
- linkend="ini.variables-order">variables_order</link> are not set, their
- appropriate PHP predefined arrays are also left empty.
+ �p�G�Y�� <link linkend="ini.variables-order">variables_order</link>
�����ܼƨS���Q�]�w�A���̬۹諸 PHP �w�]���C�]�N�|�O�Ū��C
</para>
<variablelist id="language.variables.superglobals">
- <title>PHP Superglobals</title>
+ <title>PHP �� Superglobals</title>
<varlistentry>
<term><link linkend="reserved.variables.globals">$GLOBALS</link></term>
<listitem>
<simpara>
- Contains a reference to every variable which is currently
- available within the global scope of the script. The keys of
- this array are the names of the global variables.
- <varname>$GLOBALS</varname> has existed since PHP 3.
+ [EMAIL PROTECTED]<varname>$GLOBALS</varname> �� PHP 3 �}�l�N�w�s�b�C
</simpara>
</listitem>
</varlistentry>
@@ -202,10 +135,7 @@
<term><link linkend="reserved.variables.server">$_SERVER</link></term>
<listitem>
<simpara>
- Variables set by the web server or otherwise directly related
- to the execution environment of the current script. Analogous
- to the old <varname>$HTTP_SERVER_VARS</varname> array (which is
- still available, but deprecated).
+ �Ѻ������A���]�w���ܼƩΥثe���{���Ұ��檺���Ҳ��ͪ��ܼơC��ʽ������¦���
<varname>$HTTP_SERVER_VARS</varname> ���C�A���M�ثe�٥i�H�ϥΡA�����Q��ij�C
</simpara>
</listitem>
</varlistentry>
@@ -213,9 +143,7 @@
<term><link linkend="reserved.variables.get">$_GET</link></term>
<listitem>
<simpara>
- Variables provided to the script via HTTP GET. Analogous to the
- old <varname>$HTTP_GET_VARS</varname> array (which is still
- available, but deprecated).
+ �q�L HTTP GET ���ѵ��{�����ܼơC��ʽ������¦���
<varname>$HTTP_GET_VARS</varname> ���C�A���M�ثe�٥i�H�ϥΡA�����Q��ij�C
</simpara>
</listitem>
</varlistentry>
@@ -223,9 +151,7 @@
<term><link linkend="reserved.variables.post">$_POST</link></term>
<listitem>
<simpara>
- Variables provided to the script via HTTP POST. Analogous to the
- old <varname>$HTTP_POST_VARS</varname> array (which is still
- available, but deprecated).
+ �q�L HTTP POST ���ѵ��{�����ܼơC��ʽ������¦���
<varname>$HTTP_POST_VARS</varname>���C�A���M�ثe�٥i�H�ϥΡA�����Q��ij�C
</simpara>
</listitem>
</varlistentry>
@@ -233,9 +159,7 @@
<term><link linkend="reserved.variables.cookies">$_COOKIE</link></term>
<listitem>
<simpara>
- Variables provided to the script via HTTP cookies. Analogous to
- the old <varname>$HTTP_COOKIE_VARS</varname> array (which is
- still available, but deprecated).
+ �q�L HTTP cookies ���ѵ��{�����ܼơC��ʽ������¦���
<varname>$HTTP_COOKIE_VARS</varname>���C�A���M�ثe�٥i�H�ϥΡA�����Q��ij�C
</simpara>
</listitem>
</varlistentry>
@@ -243,12 +167,7 @@
<term><link linkend="reserved.variables.files">$_FILES</link></term>
<listitem>
<simpara>
- Variables provided to the script via HTTP post file
- uploads. Analogous to the old
- <varname>$HTTP_POST_FILES</varname> array (which is still
- available, but deprecated). See <link
- linkend="features.file-upload.post-method">POST method
- uploads</link> for more information.
+ �q�L HTTP POST �ɮפW�Ǵ��ѵ��{�����ܼơC��ʽ������¦���
<varname>$HTTP_POST_FILES</varname>���C�A���M�ثe�٥i�H�ϥΡA�����Q��ij�C�Ա��аѾ\
<link linkend="features.file-upload.post-method">POST �W�Ǥ覡</link>�C
</simpara>
</listitem>
</varlistentry>
@@ -256,9 +175,7 @@
<term><link linkend="reserved.variables.environment">$_ENV</link></term>
<listitem>
<simpara>
- Variables provided to the script via the environment. Analogous
- to the old <varname>$HTTP_ENV_VARS</varname> array (which is
- still available, but deprecated).
+ �������Ҵ��ѵ��{�����ܼơC��ʽ������¦���
<varname>$HTTP_ENV_VARS</varname>���C�A���M�ثe�٥i�H�ϥΡA�����Q��ij�C
</simpara>
</listitem>
</varlistentry>
@@ -266,20 +183,11 @@
<term><link linkend="reserved.variables.request">$_REQUEST</link></term>
<listitem>
<simpara>
- Variables provided to the script via any user input mechanism,
- and which therefore cannot be trusted. The presence and order
- of variable inclusion in this array is defined according to the <link
- linkend="ini.variables-order">variables_order</link>
- configuration directive. This array has no direct analogue in
- versions of PHP prior to 4.1.0. See also
- <function>import_request_variables</function>.
+
�q�L����ϥΪ̿�J�~�|�Ӵ��ѵ��{�����ܼơA�]���]�p�����ȱo�H���C�����C���ܼƪ��s�b�P�_�Φ��ǬO�M�w��
<link linkend="ini.variables-order">variables_order</link> ���]�w�CPHP 4.1.0
���e�������èS�����������C���ܼơC�ЦP�ɰѾ\
<function>import_request_variables</function>�C
</simpara>
<note>
<simpara>
- When running on the <link linkend="features.commandline">command line
- </link>, this will <emphasis>not</emphasis> include the
- <varname>argv</varname> and <varname>argc</varname> entries; these are
- present in the <varname>$_SERVER</varname> array.
+ �b<link
linkend="features.commandline">���O��</link>�Ҧ��U����ɡA����<emphasis>��</emphasis>�]�t
<varname>argv</varname> �M <varname>argc</varname> ���ءC���ⶵ�إu�b
<varname>$_SERVER</varname> ���C���X�{�C
</simpara>
</note>
</listitem>
@@ -288,12 +196,7 @@
<term><link linkend="reserved.variables.session">$_SESSION</link></term>
<listitem>
<simpara>
- Variables which are currently registered to a script's
- session. Analogous to the old
- <varname>$HTTP_SESSION_VARS</varname> array (which is still
- available, but deprecated). See the <link
- linkend="ref.session">Session handling functions</link> section
- for more information.
+ �ثe�M�{���`�U�F�� session �ܼơC��ʽ������¦���
<varname>$HTTP_SESSION_VARS</varname>���C�A���M�ثe�٥i�H�ϥΡA�����Q��ij�C�Ա��аѾ\
<link linkend="ref.session">Session �B�z���</link>[EMAIL PROTECTED]
</simpara>
</listitem>
</varlistentry>
@@ -303,13 +206,10 @@
<sect1 id="language.variables.scope">
- <title>Variable scope</title>
+ <title>�ܼƽd��</title>
<simpara>
- The scope of a variable is the context within which it is defined.
- For the most part all PHP variables only have a single scope.
- This single scope spans included and required files as well. For
- example:
+ �ܼƪ��d��u�O�b��ҩw�q���Ŷ����s�b�C�b�j���������p�U�APHP [EMAIL
PROTECTED]@[EMAIL PROTECTED] include �M require �覡�ޤJ���ɮסC�Ҧp�G
</simpara>
<informalexample>
<programlisting role="php">
@@ -322,11 +222,7 @@
</programlisting>
</informalexample>
<simpara>
- Here the <varname>$a</varname> variable will be available within
- the included <filename>b.inc</filename> script. However, within
- user-defined functions a local function scope is introduced. Any
- variable used inside a function is by default limited to the local
- function scope. For example:
+ �Ҥl���A�ܼ� <varname>$a</varname> �]�s�b�_�Q�]�t�J���{��
<filename>b.inc</filename> [EMAIL PROTECTED]
</simpara>
<informalexample>
@@ -347,16 +243,7 @@
</informalexample>
<simpara>
- This script will not produce any output because the echo statement
- refers to a local version of the <varname>$a</varname> variable,
- and it has not been assigned a value within this scope. You may
- notice that this is a little bit different from the C language in
- that global variables in C are automatically available to
- functions unless specifically overridden by a local definition.
- This can cause some problems in that people may inadvertently
- change a global variable. In PHP global variables must be
- declared global inside a function if they are going to be used in
- that function. An example:
+ �o�ӵ{�����|��X����F��A�]�� echo �z�y�ϥΤF���ϰ쪩���� <varname>$a</varname>
[EMAIL PROTECTED]|�o�{�o�M C �y�������k���P�A�]�� C
�������ܼƬO�۰ʪ����ѵ��U��ơA���D�b����w�q�������M�P�C�����k�i��|[EMAIL
PROTECTED] PHP ���A�����ܼƦb����ϥΫe�������ŧG������C�Ҥl�G
</simpara>
<informalexample>
@@ -381,17 +268,11 @@
</informalexample>
<simpara>
- The above script will output "3". By declaring
- <varname>$a</varname> and <varname>$b</varname> global within the
- function, all references to either variable will refer to the
- global version. There is no limit to the number of global
- variables that can be manipulated by a function.
+ �W�z�Ҥl�N�|��X "3"�C�b��Ƥ��ŧG <varname>$a</varname> ��
<varname>$b</varname> �������A�Ҧ��A�θӨ���ܼƪ��ϥαN�۰ʫ��V���쪺�����CPHP
[EMAIL PROTECTED]
</simpara>
<simpara>
- A second way to access variables from the global scope is to use
- the special PHP-defined <varname>$GLOBALS</varname> array. The
- previous example can be rewritten as:
+ [EMAIL PROTECTED] PHP
�S�O�w�q�����C�G<varname>$GLOBALS</varname>�C�e�����Ҥl�i�H���g���G
</simpara>
<informalexample>
@@ -414,13 +295,7 @@
</informalexample>
<simpara>
- The <varname>$GLOBALS</varname> array is an associative array with
- the name of the global variable being the key and the contents of
- that variable being the value of the array element.
- Notice how <varname>$GLOBALS</varname> exists in any scope, this
- is because $GLOBALS is a <link
- linkend="language.variables.superglobals">superglobal</link>.
- Here's an example demonstrating the power of superglobals:
+ <varname>$GLOBALS</varname> [EMAIL PROTECTED] (associative
array)�A�����ܼƪ��W�Y��������A�Ӹ��ܼƪ����e�Y�����C���ȡC���_�d�N��
<varname>$GLOBALS</varname> [EMAIL PROTECTED] $GLOBALS [EMAIL PROTECTED]<link
linkend="language.variables.superglobals">superglobal</link>[EMAIL PROTECTED]
superglobals �j�j�\��Ҥl�G
</simpara>
<para>
@@ -448,11 +323,7 @@
</para>
<simpara>
- Another important feature of variable scoping is the
- <emphasis>static</emphasis> variable. A static variable exists
- only in a local function scope, but it does not lose its value
- when program execution leaves this scope. Consider the following
- example:
+ [EMAIL
PROTECTED]<emphasis>�R�A</emphasis>�ܼơC�R�A�ܼƥu�b�����ƽd�s�b�A���O���{���������}���d��ɡA���ä��|�ॢ�����ȡC�ݬݤU�����Ҥl�G
</simpara>
<informalexample>
@@ -471,13 +342,7 @@
</informalexample>
<simpara>
- This function is quite useless since every time it is called it
- sets <varname>$a</varname> to <literal>0</literal> and prints
- "0". The <varname>$a</varname>++ which increments the
- variable serves no purpose since as soon as the function exits the
- <varname>$a</varname> variable disappears. To make a useful
- counting function which will not lose track of the current count,
- the <varname>$a</varname> variable is declared static:
+ [EMAIL PROTECTED] <varname>$a</varname> �]�� <literal>0</literal> �M��C�L�X
"0"�C<varname>$a</varname>++ �W�[�F <varname>$a</varname> [EMAIL PROTECTED]
<varname>$a</varname> [EMAIL PROTECTED]|�ᥢ���e�p�ƪ��p�ƨ�ơA�ڭ̥i�H�N
<varname>$a</varname>�ŧG���R�A�G
</simpara>
<informalexample>
@@ -496,18 +361,11 @@
</informalexample>
<simpara>
- Now, every time the Test() function is called it will print the
- value of <varname>$a</varname> and increment it.
+ �{�b�A�C����� Test() �Q�I�s�ɡA���|�C�L�X <varname>$a</varname> [EMAIL PROTECTED]
</simpara>
<simpara>
- Static variables also provide one way to deal with recursive
- functions. A recursive function is one which calls itself. Care
- must be taken when writing a recursive function because it is
- possible to make it recurse indefinitely. You must make sure you
- have an adequate way of terminating the recursion. The following
- simple function recursively counts to 10, using the static
- variable <varname>$count</varname> to know when to stop:
+ [EMAIL
PROTECTED]@�ةI�s�ۤv����ơC�s�g���j��Ʈɥ����d�N�A�]���Y�s�g���~�A�����i��|�L�w���a���j�C�z�����T�w�������覡�Ӳפ�j�C�U�C²�檺��ƱN���j�a�ƨ�
10�A�Q���R�A�ܼ� <varname>$count</varname> ���_�w����ɭ���G
</simpara>
<informalexample>
@@ -531,12 +389,7 @@
</informalexample>
<simpara>
- The Zend Engine 1, driving <literal>PHP4</literal>, implements the
- <literal>static</literal> and <literal>global</literal> modifier for
- variables in terms of references. For example, a true global variable
- imported inside a function scope with the <literal>global</literal>
- statement actually creates a reference to the global variable. This can
- lead to unexpected behaviour which the following example addresses:
+ �X�� <literal>PHP 4</literal> �� Zend Engine 1 �O�H�ѷӪ��覡�ӹ�{
<literal>static</literal> �M <literal>global</literal> [EMAIL PROTECTED]
<literal>global</literal> [EMAIL PROTECTED]@[EMAIL PROTECTED]
</simpara>
<informalexample>
@@ -563,7 +416,7 @@
</informalexample>
<simpara>
- Executing this example will result in the following output:
+ ����o�ӨҤl�N�|�ɭP�U�C����X�G
</simpara>
<screen>
@@ -573,8 +426,7 @@
</screen>
<simpara>
- A similar behaviour applies to the <literal>static</literal> statement.
- References are not stored statically:
+ <literal>static</literal> ���z���]�|�ɭP�P�˪���X�C�ѷӨèS���Q�R�A�a�x�s�G
</simpara>
<informalexample>
@@ -618,7 +470,7 @@
</informalexample>
<simpara>
- Executing this example will result in the following output:
+ ���榹�Ҥl�N�ɭP�U�C����X�G
</simpara>
<screen>
@@ -633,21 +485,17 @@
</screen>
<simpara>
- This example demonstrates that when assigning a reference to a static
- variable, it's not <emphasis>remembered</emphasis> when you call the
- <literal>&get_instance_ref()</literal> function a second time.
+ [EMAIL PROTECTED]@���R�A�ܼƫ�A���z�ĤG���I�s
<literal>&get_instance_ref()</literal>
��ƮɡA���O<emphasis>���|</emphasis>�O�����e���Ȫ��C
</simpara>
</sect1>
<sect1 id="language.variables.variable">
- <title>Variable variables</title>
+ <title>�i���ܼ�</title>
<simpara>
- Sometimes it is convenient to be able to have variable variable
- names. That is, a variable name which can be set and used
- dynamically. A normal variable is set with a statement such as:
+ ���ɭԡA�i�H�ϥΥi���ܼƷ|[EMAIL PROTECTED]@[EMAIL PROTECTED]
</simpara>
<informalexample>
@@ -661,10 +509,7 @@
</informalexample>
<simpara>
- A variable variable takes the value of a variable and treats that
- as the name of a variable. In the above example,
- <emphasis>hello</emphasis>, can be used as the name of a variable
- by using two dollar signs. i.e.
+ [EMAIL PROTECTED]@[EMAIL PROTECTED] $ �b <emphasis>hello</emphasis> [EMAIL
PROTECTED]@���ܼƪ��W�ӨϥΤF�C�Y�G
</simpara>
<informalexample>
@@ -678,10 +523,7 @@
</informalexample>
<simpara>
- At this point two variables have been defined and stored in the
- PHP symbol tree: <varname>$a</varname> with contents "hello" and
- <varname>$hello</varname> with contents "world". Therefore, this
- statement:
+ �o�ɡA������ܼƳQ�w�q�M���x�s�b PHP ���Ÿ������G�t�� "hello" ��
<varname>$a</varname> �Χt�� "world" �� <varname>$hello</varname>�C�ҥH�A���ԭz�G
</simpara>
<informalexample>
@@ -695,7 +537,7 @@
</informalexample>
<simpara>
- produces the exact same output as:
+ �P�U�C�o�y���ۦP�˪���X�G
</simpara>
<informalexample>
@@ -709,48 +551,34 @@
</informalexample>
<simpara>
- i.e. they both produce: <computeroutput>hello world</computeroutput>.
+ �Y�A���̳���X�G<computeroutput>hello world</computeroutput>�C
</simpara>
<simpara>
- In order to use variable variables with arrays, you have to
- resolve an ambiguity problem. That is, if you write
- <varname>$$a[1]</varname> then the parser needs to know if you
- meant to use <varname>$a[1]</varname> as a variable, or if you
- wanted <varname>$$a</varname> as the variable and then the [1]
- index from that variable. The syntax for resolving this ambiguity
- is: <varname>${$a[1]}</varname> for the first case and
- <varname>${$a}[1]</varname> for the second.
+ [EMAIL PROTECTED] <varname>$$a[1]</varname>�A����R���������D�z�O�Q��
<varname>$a[1]</varname> �O�ܼƨӨϥΡA�٬O�� <varname>$$a</varname>
�O�ܼơA�M����V�����ܼƪ��� [1] [EMAIL PROTECTED]
<varname>${$a[1]}</varname>�B�ĤG�ӱ��p�ϥ� <varname>${$a}[1]</varname>�C
</simpara>
<warning>
<simpara>
- Please note that variable variables cannot be used with PHP's
- <link linkend="language.variables.superglobals">Superglobal arrays</link>.
- This means you cannot do things like <varname>${$_GET}</varname>. If you are
- looking for a way to handle availability of superglobals and the old
- <varname>HTTP_*_VARS</varname>, you might want to try
- <link linkend="language.references">referencing</link> them.
+ �����d�N���O�A�i���ܼƬO����ϥΩ� PHP �� <link
linkend="language.variables.superglobals">Superglobal ���C</link>�C�o���ܱz����ϥ�
<varname>${$_GET}</varname> �o�˪��ԭz�C�p�G�z�u���Q�ϥ� superglobals �M�ª�
<varname>HTTP_*_VARS</varname>�A�z�i�H���եH<link
linkend="language.references">�ѷ�</link>���覡�ϥΡC
</simpara>
</warning>
</sect1>
<sect1 id="language.variables.external">
- <title>Variables from outside PHP</title>
+ <title>�Ӧ� PHP �H�~���ܼ�</title>
<sect2 id="language.variables.external.form">
- <title>HTML Forms (GET and POST)</title>
+ <title>HTML ���� (GET �MPOST)</title>
<simpara>
- When a form is submitted to a PHP script, the information from
- that form is automatically made available to the script. There
- are many ways to access this information, for example:
+ [EMAIL PROTECTED] PHP
�{���ɡA���椺����T�N�۰ʴ��ѵ��ӵ{���C�ڭ̦��ܦh��k�s���o�Ǹ�T�A�d�ҡG
</simpara>
<para>
<example>
- <title>A simple HTML form</title>
+ <title>[EMAIL PROTECTED] HTML ����</title>
<programlisting role="html">
<![CDATA[
<form action="foo.php" method="post">
@@ -764,13 +592,12 @@
</para>
<para>
- Depending on your particular setup and personal preferences, there
- are many ways to access data from your HTML forms. Some examples are:
+ �ھڱz���w�ˤ覡�M�ӤH���n�APHP ���Ѧh�ؤ覡�s�� HTML [EMAIL PROTECTED]
</para>
<para>
<example>
- <title>Accessing data from a simple POST HTML form</title>
+ <title>[EMAIL PROTECTED] POST �覡�ǰe��²�� HTML ����</title>
<programlisting role="html">
<![CDATA[
<?php
@@ -782,7 +609,7 @@
import_request_variables('p', 'p_');
print $p_username;
-// Available since PHP 3. As of PHP 5.0.0, these long predefined
+// Available since PHP 3. As of PHP 5.0.0, these long predefined
// variables can be disabled with the register_long_arrays directive.
print $HTTP_POST_VARS['username'];
@@ -798,55 +625,33 @@
</example>
</para>
<para>
- Using a GET form is similar except you'll use the appropriate
- GET predefined variable instead. GET also applies to the
- QUERY_STRING (the information after the '?' in an URL). So,
- for example, <literal>http://www.example.com/test.php?id=3</literal>
- contains GET data which is accessible with <varname>$_GET['id']</varname>.
- See also <link linkend="reserved.variables.request">$_REQUEST</link> and
- <function>import_request_variables</function>.
+ �ϥ� GET �覡�ǰe������Ϊk�����A�u���L�ϥΦX�A�����e�w�q����ơCGET
�]�i�ϥΦb�d�ߦr�� (QUERY_STRING) �qURL ���ݸ� '?'
�᭱����T�r�C�Ҧp�A<literal>http://www.example.com/test.php?id=3</literal> �t���H
<varname>$_GET['id']</varname> �覡�s���� GET ��ơC�аѦ� <link
linkend="reserved.variables.request">$_REQUEST</link> �M
<function>import_request_variables()</function>�C
</para>
<note>
<para>
- <link linkend="language.variables.superglobals">Superglobal arrays</link>,
- like <varname>$_POST</varname> and <varname>$_GET</varname>, became
- available in PHP 4.1.0
+ <link linkend="language.variables.superglobals">Superglobal ���C</link>�p
<varname>$_POST</varname> �� <varname>$_GET</varname> �b PHP ���� 4.1.0
�H�W�~�}�l���ѡC
</para>
</note>
<para>
- As shown, before PHP 4.2.0 the default value for <link
- linkend="ini.register-globals">register_globals</link>
- was <emphasis>on</emphasis>. And, in PHP 3 it was always on. The PHP
- community is encouraging all to not rely on this directive
- as it's preferred to assume it's <emphasis>off</emphasis> and code
- accordingly.
+ �W������A�b PHP 4.2.0 ���e���������A<link
linkend="ini.register-globals">register_globals</link> ���w�]�ȬO
<emphasis>on</emphasis>�C�Ӧb PHP 3 ���A���û��O on [EMAIL PROTECTED]
<emphasis>off</emphasis> �ӳ]�p�z���{���C
</para>
<note>
<para>
- The <link linkend="ini.magic-quotes-gpc">magic_quotes_gpc</link>
- configuration directive affects Get, Post and Cookie values. If
- turned on, value (It's "PHP!") will automagically become (It\'s \"PHP!\").
- Escaping is needed for DB insertion. See also
- <function>addslashes</function>, <function>stripslashes</function> and
- <link linkend="ini.magic-quotes-sybase">magic_quotes_sybase</link>.
+ <link linkend="ini.magic-quotes-gpc">magic_quotes_gpc</link> �պA���O�|�v�T��
Get�APost �M Cookie ���ȡC�p�G�}�Ҧ����O�A(It's "PHP!") ���ȱN�ܦ� (It\'s
\"PHP!\")[EMAIL PROTECTED]
<function>addslashes</function>�A<function>stripslashes</function> �M <link
linkend="ini.magic-quotes-sybase">magic_quotes_sybase</link>�C
</para>
</note>
<simpara>
- PHP also understands arrays in the context of form variables
- (see the <link linkend="faq.html">related faq</link>). You may,
- for example, group related variables together, or use this
- feature to retrieve values from a multiple select input. For
- example, let's post a form to itself and upon submission display
- the data:
+ PHP �]���o�B�z���C���������ܼơq�а��[������ <link
linkend="faq.html">FAQ</link>�r�C�z�i�H�N�������ܼ��k���A�ΥΦ��\��Ө��^�h����ܿ�J���檺�ȡC�b�U�C�d�Ҥ��A�ڭ̱N����i�K�쥦�ۤv�A�æb�ǰe�������ܥX�ӡG
+
</simpara>
<para>
<example>
- <title>More complex form variables</title>
+ <title>������������ܼ�</title>
<programlisting role="php">
<![CDATA[
<?php
@@ -880,16 +685,14 @@
</para>
<para>
- In PHP 3, the array form variable usage is limited to
- single-dimensional arrays. In PHP 4, no such restriction applies.
+ PHP 3 [EMAIL PROTECTED] PHP 4 �h�S��������C
</para>
<sect3 id="language.variables.external.form.submit">
- <title>IMAGE SUBMIT variable names</title>
+ <title>IMAGE SUBMIT �ܼƦW��</title>
<simpara>
- When submitting a form, it is possible to use an image instead
- of the standard submit button with a tag like:
+ �b�ǰe����ɡA�ڭ̥i�H�ϥΤU�C���ұN�зǪ�������H�Ϲ��Ө��N�G
</simpara>
<informalexample>
@@ -901,13 +704,7 @@
</informalexample>
<simpara>
- When the user clicks somewhere on the image, the accompanying
- form will be transmitted to the server with two additional
- variables, sub_x and sub_y. These contain the coordinates of the
- user click within the image. The experienced may note that the
- actual variable names sent by the browser contains a period
- rather than an underscore, but PHP converts the period to an
- underscore automatically.
+ [EMAIL
PROTECTED]@�U�A���H������N�|�ǰe����A���A�H��Ө��٪��[�F����ܼơAsub_x �M
sub_y�C�o�]�t�F�ϥΪ̫��b�Ϲ����y�СC���g�窺�ϥΪ̩γ\���D���s�����ǰe�Ӫ��ܼƦW�����ӥ]�t�y���A�Ӥ��O���u�A��
PHP �۰ʦa�N�y���ഫ�������u�C
</simpara>
</sect3>
@@ -917,24 +714,12 @@
<title>HTTP Cookies</title>
<simpara>
- PHP transparently supports HTTP cookies as defined by <ulink
- url="&spec.cookies;">Netscape's Spec</ulink>. Cookies are a
- mechanism for storing data in the remote browser and thus
- tracking or identifying return users. You can set cookies using
- the <function>setcookie</function> function. Cookies are part of
- the HTTP header, so the SetCookie function must be called before
- any output is sent to the browser. This is the same restriction
- as for the <function>header</function> function. Cookie data
- is then available in the appropriate cookie data arrays, such
- as <varname>$_COOKIE</varname>, <varname>$HTTP_COOKIE_VARS</varname>
- as well as in <varname>$_REQUEST</varname>. See the
- <function>setcookie</function> manual page for more details and
- examples.
+ PHP ����䴩 <ulink
+ url="&spec.cookies;">Netscape�W��</ulink>�� HTTP cookies�CCookies
�O�ΨӱN����x�s�b�Τ�ݪ��s�������A�H�K���l�ܩ��ѧO��^���ϥΪ̡C�z�i�H��
<function>setcookie()</function> ��ƨӳ]�w cookies�CCookies �O HTTP header [EMAIL
PROTECTED] SetCookie [EMAIL PROTECTED] <function>header()</function>
��Ʀ��۬ۦP�����w�CCookie ��ƥi�H�b
<varname>$_COOKIE</varname>�A<varname>$HTTP_COOKIE_VARS</varname> ��
<varname>$_REQUEST</varname> ���C���ѨϥΡC�Ա��M�d�ҽаѦҤ�U��
<function>setcookie()</function> �����C
</simpara>
<simpara>
- If you wish to assign multiple values to a single cookie variable, you
- may assign it as an array. For example:
+ [EMAIL PROTECTED] cookie �ܼơA���z�N�n�ϥγ��C�ӫ����F�C�d�ҡG
</simpara>
<informalexample>
@@ -949,21 +734,15 @@
</informalexample>
<simpara>
- That will create two seperate cookies although MyCookie will now
- be a single array in your script. If you want to set just one cookie
- with multiple values, consider using <function>serialize</function> or
- <function>explode</function> on the value first.
+ �o�N�|�إߨ�ӭӧO�� cookies�A���{�b [EMAIL PROTECTED]@�� cookie
�إߦh�ӭȡA���z�i���墨�ǭȨϥ� <function>serialize()</function> ��
<function>explode()</function> ��ơC
</simpara>
<simpara>
- Note that a cookie will replace a previous cookie by the same
- name in your browser unless the path or domain is different. So,
- for a shopping cart application you may want to keep a counter
- and pass this along. i.e.
+ [EMAIL PROTECTED]@�� cookie �N�|[EMAIL PROTECTED] cookie�A���D�� cookie
�����|[EMAIL PROTECTED]
</simpara>
<example>
- <title>A <function>setcookie</function> example</title>
+ <title>[EMAIL PROTECTED] <function>setcookie()</function> ���d��</title>
<programlisting role="php">
<![CDATA[
<?php
@@ -978,13 +757,11 @@
</sect2>
<sect2 id="language.variables.external.dot-in-names">
- <title>Dots in incoming variable names</title>
+ <title>�b�ܼƦW�r�����y�� (dots)</title>
<para>
- Typically, PHP does not alter the names of variables when they
- are passed into a script. However, it should be noted that the
- dot (period, full stop) is not a valid character in a PHP
- variable name. For the reason, look at it:
+ [EMAIL PROTECTED] �ä��|���ǤJ�{�����ܼƦW�١C�M�ӡA�z�����d�N�y�� (.) [EMAIL
PROTECTED] PHP �ܼƦW�٦r���A���p�G
+
<programlisting role="php">
<![CDATA[
<?php
@@ -992,34 +769,20 @@
?>
]]>
</programlisting>
- Now, what the parser sees is a variable named
- <varname>$varname</varname>, followed by the string concatenation
- operator, followed by the barestring (i.e. unquoted string which
- doesn't match any known key or reserved words) 'ext'. Obviously,
- this doesn't have the intended result.
+ [EMAIL PROTECTED] <varname>$varname</varname> ���ܼơA���H�ۦr��s���B��l
(.)[EMAIL PROTECTED]|�a�ӱz�Q�n�����G�C
</para>
<para>
- For this reason, it is important to note that PHP will
- automatically replace any dots in incoming variable names with
- underscores.
+ ���]�p���APHP �|�۰ʪ��N�ǤJ���ܼƦW�٤����y�� (.) �אּ���u (_)�C
</para>
</sect2>
<sect2 id="language.variables.determining-type-of">
- <title>Determining variable types</title>
+ <title>�P�w�ܼƪ�����</title>
<para>
- Because PHP determines the types of variables and converts them
- (generally) as needed, it is not always obvious what type a given
- variable is at any one time. PHP includes several functions
- which find out what type a variable is, such as:
- <function>gettype</function>, <function>is_array</function>,
- <function>is_float</function>, <function>is_int</function>,
- <function>is_object</function>, and
- <function>is_string</function>. See also the chapter on
- <link linkend="language.types">Types</link>.
+ �ѩ� PHP �|[EMAIL PROTECTED]
���ѤF�X�ӧP�w�ܼ���������ơG<function>gettype()</function>�B<function>is_array()</function>�B<function>is_float()</function>�B<function>is_int()</function>�B<function>is_object()</function>
�� <function>is_string()</function>�C�аѾ\<link
linkend="language.types">����</link>[EMAIL PROTECTED]
</para>
</sect2>
@@ -1046,4 +809,4 @@
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
--->
+-->
\ No newline at end of file
--
PHP Documentation Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php