CVS update: php3/doc/chapters
| From: | cslawi | Date: | Sat, 21 Nov 1998 23:04:56 +0000 |
| Subject: | CVS update: php3/doc/chapters | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-2520@lists.php.net to get a copy of this message | ||
Date: Saturday November 21, 1998 @ 18:04
Author: cslawi
Update of /repository/php3/doc/chapters
In directory asf:/u2/tmp/cvs-serv12827/chapters
Modified Files:
lang-syntax.sgml
Log Message:
Add some information about variable types, GET & POST variables from
forms, and updated some crossrefs.
Index: php3/doc/chapters/lang-syntax.sgml
diff -c php3/doc/chapters/lang-syntax.sgml:1.21 php3/doc/chapters/lang-syntax.sgml:1.22
*** php3/doc/chapters/lang-syntax.sgml:1.21 Thu Oct 8 08:28:55 1998
--- php3/doc/chapters/lang-syntax.sgml Sat Nov 21 18:04:56 1998
***************
*** 33,42 ****
<title>Instruction separation</title>
<simpara></simpara>
<sect1 id="variable-types">
<title>Variable types</title>
! <simpara></simpara>
<sect1 id="variable-init">
<title>Variable initialization</title>
<simpara>
--- 33,71 ----
<title>Instruction separation</title>
<simpara></simpara>
+
<sect1 id="variable-types">
<title>Variable types</title>
! <para>
! PHP supports the following types:
+ <itemizedlist>
+ <listitem><simpara>integer
+ <listitem><simpara>double
+ <listitem><simpara>string
+ <listitem><simpara>array
+ <listitem><simpara>object
+ </itemizedlist>
+
+ <simpara>
+ The type of a variable is usually not set by the programmer;
+ rather, it is decided at runtime by PHP depending on the context
+ in which that variable is used.
+
+ <simpara>
+ If you would like to force a variable to be converted to a certain
+ type, you may either <link
+ linkend="lang-syntax.typecasting">cast</link> the variable or use
+ the <function>settype</function> function on it.
+
+ <simpara>
+ Note that a variable may behave in different manners in certain
+ situations, depending on what type it is a the time. For more
+ information, see the section on <link
+ linkend="variable-typejuggling">Type Juggling</link>.
+
+ </sect1>
+
<sect1 id="variable-init">
<title>Variable initialization</title>
<simpara>
***************
*** 239,246 ****
<sect2>
<title>HTML Forms (GET and POST)</title>
! <simpara></simpara>
<sect3>
<title>IMAGE SUBMIT variable names</TITLE>
<simpara>
--- 268,324 ----
<sect2>
<title>HTML Forms (GET and POST)</title>
! <simpara>
! When a form is submitted to a PHP script, any variables from that
! form will be automatically made available to the script by
! PHP. For instance, consider the following form:
!
! <para>
! <example>
! <title>Simple form variable</title>
! <programlisting>
! <form action="foo.php3" method="post">
! Name: <input type="text" name="name"><br>
! <input type="submit">
! </form>
! </programlisting>
! </example>
+ When submitted, PHP will create the variable
+ <computeroutput>$name</computeroutput>, which will will contain
+ whatever what entered into the <emphasis>Name:</emphasis> field
+ on the form.
+
+ <simpara>
+ PHP also understands arrays in the context of form variables, but
+ only in one dimension. You may, for example, group related
+ variables together, or use this feature to retrieve values from a
+ multiple select input:
+
+ <para>
+ <example>
+ <title>More complex form variables</title>
+ <programlisting>
+ <form action="array.html" method="post">
+ Name: <input type="text"
name="personal[name]"><br>
+ Email: <input type="text"
name="personal[email]"><br>
+ Beer: <br>
+ <select multiple name="beer[]">
+ <option value="warthog">Warthog
+ <option value="guinness">Guinness
+ </select>
+ <input type="submit">
+ </form>
+ </programlisting>
+ </example>
+
+ If PHP's track_vars feature is turned on, either by the <link
+ linkend="ini.track-vars">track_vars</link> configuration setting
+ or the <computeroutput><?php_track_vars?></computeroutput>
+ directive, then variables submitted via the POST or GET methods
+ will also be found in the global associative arrays
+ $HTTP_POST_VARS and $HTTP_GET_VARS as appropriate.
+
<sect3>
<title>IMAGE SUBMIT variable names</TITLE>
<simpara>
***************
*** 309,315 ****
<simpara>
</simpara>
! <sect1 id="typejuggling">
<title>Type juggling</title>
<simpara>
PHP does not require (or support) explicit type definition in
--- 387,393 ----
<simpara>
</simpara>
! <sect1 id="variable-typejuggling">
<title>Type juggling</title>
<simpara>
PHP does not require (or support) explicit type definition in
***************
*** 428,450 ****
<sect1 id="variable-arrays">
<title>Array manipulation</title>
<para>
! PHP supports both scalar and associative arrays. In fact, there is no
! difference between the two. You can create an array using the
! <function>array</function> function, or you can explicitly set each
! array element value.
! <informalexample><programlisting>
! $a[0] = "abc";
! $a[1] = "def";
$b["foo"] = 13;
! </programlisting></informalexample>
<para>
! Arrays may be sorted using the <function>sort</function>,
<function>ksort</function>
! and <function>asort</function> functions depending on the type of sort you want.
<para>
! You can count the number of items in an array using the <function>count</function>
function.
<para>
! You can traverse an array using <function>next</function> and
<function>prev</function> functions.
! Another common way to traverse an array is to use the <function>each</function>
</chapter>
<!-- Keep this comment at the end of the file
--- 506,538 ----
<sect1 id="variable-arrays">
<title>Array manipulation</title>
<para>
! PHP supports both scalar and associative arrays. In fact, there is
! no difference between the two. You can create an array using the
! <function>array</function> function, or you can explicitly set
! each array element value.
! <informalexample><programlisting>
! $a[0] = "abc";
! $a[1] = "def";
$b["foo"] = 13;
! </programlisting></informalexample>
!
<para>
! Arrays may be sorted using the <function>asort</function>,
! <function>arsort</function>, <function>ksort</function>,
! <function>rsort</function>, <function>sort</function>,
! <function>uasort</function>, <function>usort</function>,
! and <function>uksort</function> functions depending on the type of
! sort you want.
!
<para>
! You can count the number of items in an array using the
! <function>count</function> function.
!
<para>
! You can traverse an array using <function>next</function> and
! <function>prev</function> functions. Another common way to
! traverse an array is to use the <function>each</function> function.
!
</chapter>
<!-- Keep this comment at the end of the file
--
PHP Development Mailing List http://www.php.net/
To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net
For help: php-dev-help@lists.php.net