CVS update: php3/doc/chapters

From: Date: Tue, 25 May 1999 05:11:44 +0000
Subject: CVS update: php3/doc/chapters
Groups: php.dev 
Request: Send a blank email to php-dev+get-5969@lists.php.net to get a copy of this message
Date: Tuesday May 25, 1999 @ 1:11 Author: jim Update of /repository/php3/doc/chapters In directory php:/tmp/cvs-serv27486 Modified Files: features.sgml intro.sgml lang-const.sgml lang-syntax.sgml Log Message: More shuffling, and change some explicit PHP3 references to just say PHP. Index: php3/doc/chapters/features.sgml diff -u php3/doc/chapters/features.sgml:1.30 php3/doc/chapters/features.sgml:1.31 --- php3/doc/chapters/features.sgml:1.30 Mon May 24 21:13:05 1999 +++ php3/doc/chapters/features.sgml Tue May 25 01:11:44 1999 @@ -1,5 +1,5 @@ <chapter id="features"> - <title>PHP3 features</title> + <title>Features</title> <simpara></simpara> <sect1 id="feature-httpauth"> @@ -320,31 +320,6 @@ </sect1> - <sect1 id="feature-databases"> - <title>Database support</title> - - <para> - PHP supports a number of different databases in both native mode - and through ODBC, including: - - <simplelist columns=2> - <member>Adabas D</member> - <member>dBase</member> - <member>Empress</member> - <member>FilePro</member> - <member>Informix</member> - <member>InterBase</member> - <member>mSQL</member> - <member>MySQL</member> - <member>Oracle</member> - <member>PostgreSQL</member> - <member>Solid</member> - <member>Sybase</member> - <member>Velocis</member> - <member>Unix dbm</member> - </simplelist> - - <sect1 id="feature-regexps"> <title>Regular expressions</title> @@ -504,10 +479,6 @@ returns a bitfield of the active states. So, if both states are active it would return 3, for example. </simpara> </sect1> - - <sect1 id="feature-source-viewer"> - <title>PHP source viewer</title> - <simpara></simpara> </chapter> Index: php3/doc/chapters/intro.sgml diff -u php3/doc/chapters/intro.sgml:1.12 php3/doc/chapters/intro.sgml:1.13 --- php3/doc/chapters/intro.sgml:1.12 Fri Oct 23 07:39:06 1998 +++ php3/doc/chapters/intro.sgml Tue May 25 01:11:44 1999 @@ -1,14 +1,14 @@ <chapter id="introduction"> - <title>An introduction to PHP3</title> + <title>Introduction</title> <simpara></simpara> <sect1 id="intro-whatis"> - <title>What is PHP3?</title> + <title>What is PHP?</title> <simpara> - PHP Version 3.0 is a server-side HTML-embedded scripting language. + PHP is a server-side HTML-embedded scripting language. <sect1 id="intro-whatcando"> - <title>What can PHP3 do?</title> + <title>What can PHP do?</title> <para> Perhaps the strongest and most significant feature in PHP3 is its database integration layer. Writing a database-enabled web page @@ -16,25 +16,26 @@ supported: <blockquote> <simplelist columns=2> - <member>Oracle</member> - <member>Sybase</member> + <member>Adabas D</member> + <member>dBase</member> + <member>Empress</member> + <member>FilePro</member> + <member>Informix</member> + <member>InterBase</member> <member>mSQL</member> <member>MySQL</member> - <member>Solid</member> - <member>ODBC</member> + <member>Oracle</member> <member>PostgreSQL</member> - <member>Adabas D</member> - <member>FilePro</member> + <member>Solid</member> + <member>Sybase</member> <member>Velocis</member> - <member>Informix</member> - <member>dBase</member> <member>Unix dbm</member> </simplelist> </blockquote> <!-- <sect1 id="intro-concepts"> - <title>PHP3 Concepts</title> + <title>PHP Concepts</title> <simpara></simpara> --> Index: php3/doc/chapters/lang-const.sgml diff -u php3/doc/chapters/lang-const.sgml:1.41 php3/doc/chapters/lang-const.sgml:1.42 --- php3/doc/chapters/lang-const.sgml:1.41 Tue May 25 00:15:40 1999 +++ php3/doc/chapters/lang-const.sgml Tue May 25 01:11:44 1999 @@ -787,7 +787,7 @@ </informalexample> <simpara> - Any valid PHP3 code may appear inside a function, even other + Any valid PHP code may appear inside a function, even other functions and <link linkend="keyword.class">class</link> definitions. @@ -834,7 +834,7 @@ which is a comma-delimited list of variables and/or constants. <para> - PHP3 supports passing arguments by value (the default), <link + PHP supports passing arguments by value (the default), <link linkend="keyword.function.arguments.reference">passing by reference</link>, and <link linkend="keyword.function.arguments.default">default argument Index: php3/doc/chapters/lang-syntax.sgml diff -u php3/doc/chapters/lang-syntax.sgml:1.41 php3/doc/chapters/lang-syntax.sgml:1.42 --- php3/doc/chapters/lang-syntax.sgml:1.41 Tue May 25 00:23:12 1999 +++ php3/doc/chapters/lang-syntax.sgml Tue May 25 01:11:44 1999 @@ -215,33 +215,135 @@ <sect2 id="types.array"> <title>Arrays</title> - <sect3 id="types.array.init"> - <title>Array Initialization</title> + <para> + Arrays actually act like both hash tables (associative arrays) + and indexed arrays (vectors). - <simpara> - An array may be initialized in one of two ways: by the sequential - assigning of values, and by using the <function>array</function> - construct (which is documented in the <link - linkend="ref.array">Array functions</link> section). - + <sect3 id="types.array.single-dim"> + <title>Single Dimension Arrays</title> + <para> - To sequentially add values to an array, you simply assign to the - array variable using an empty subscript. The value will be added - as the last element of the array. + PHP supports both scalar and associative arrays. In fact, there + is no difference between the two. You can create an array using + the <function>list</function> or <function>array</function> + functions, or you can explicitly set each array element value. - <informalexample> - <programlisting> -$names[] = "Jill"; // $names[0] = "Jill" -$names[] = "Jack"; // $names[1] = "Jack" - </programlisting> - </informalexample> + <informalexample> + <programlisting role="php"> +$a[0] = "abc"; +$a[1] = "def"; +$b["foo"] = 13; + </programlisting> + </informalexample> + + <para> + You can also create an array by simply adding values to + the array. + + <informalexample> + <programlisting role="php"> +$a[] = "hello"; // $a[2] == "hello" +$a[] = "world"; // $a[3] == "world" + </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. + + <sect3 id="types.array.multi-dim"> + <title>Multi-Dimensional Arrays</title> + + <para> + Multi-dimensional arrays are actually pretty simple. For each + dimension of the array, you add another [key] value to the end: + + <informalexample> + <programlisting role="php"> +$a[1] = $f; # one dimensional examples +$a["foo"] = $f; + +$a[1][0] = $f; # two dimensional +$a["foo"][2] = $f; # (you can mix numeric and associative indices) +$a[3]["bar"] = $f; # (you can mix numeric and associative indices) + +$a["foo"][4]["bar"][0] = $f; # four dimensional! + </programlisting> + </informalexample> + + <para> + You can "fill up" multi-dimensional arrays in many ways, + but the trickiest one to understand is how to use the + <function>array</function> command for associative arrays. + These two snippets of code fill up the one-dimensional array in + the same way: + + <informalexample> + <programlisting role="php"> +# Example 1: + +$a["color"] = "red"; +$a["taste"] = "sweet"; +$a["shape"] = "round"; +$a["name"] = "apple"; +$a[3] = 4; + +# Example 2: +$a = array( + "color" => "red", + "taste" => "sweet", + "shape" => "round", + "name" => "apple", + 3 => 4 +); + </programlisting> + </informalexample> + <para> - As in C and Perl, array elements are numbered starting with 0, - not 1. - - </sect2> + The <function>array</function> function can be nested for + multi-dimensional arrays: + + <informalexample> + <programlisting role="php"> +&lt;? +$a = array( + "apple" => array( + "color" => "red", + "taste" => "sweet", + "shape" => "round" + ), + "orange" => array( + "color" => "orange", + "taste" => "sweet", + "shape" => "round" + ), + "banana" => array( + "color" => "yellow", + "taste" => "paste-y", + "shape" => "banana-shaped" + ) +); +echo $a["apple"]["taste"]; # will output "sweet" +?> + </programlisting> + </informalexample> + <sect2 id="types.object"> <title>Objects</title> @@ -275,10 +377,10 @@ value". <simpara> - Simple examples that come in mind are constants and variables. - When you type "$a = 5", you're assigning '5' into $a. '5', - obviously, has the value 5, or in other words '5' is an expression - with the value of 5 (in this case, '5' is an integer constant). + The most basic forms of expressions are constants and variables. + When you type "$a = 5", you're assigning '5' into $a. '5', obviously, + has the value 5, or in other words '5' is an expression with the + value of 5 (in this case, '5' is an integer constant). <simpara> After this assignment, you'd expect $a's value to be 5 as @@ -937,139 +1039,6 @@ <simpara> For more information on this conversion, see the Unix manual page for strtod(3). - - <sect1 id="variable-arrays"> - <title>Array manipulation</title> - - <sect2 id="variable-arrays.single-dim"> - <title>Single Dimension Arrays</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>list</function> or <function>array</function> - functions, or you can explicitly set each array element value. - - <informalexample> - <programlisting role="php"> -$a[0] = "abc"; -$a[1] = "def"; -$b["foo"] = 13; - </programlisting> - </informalexample> - - <para> - You can also create an array by simply adding values to - the array. - - <informalexample> - <programlisting role="php"> -$a[] = "hello"; // $a[2] == "hello" -$a[] = "world"; // $a[3] == "world" - </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. - - </sect2> - - <sect2 id="variable-arrays.multi-dim"> - <title>Multi-Dimensional Arrays</title> - - <para> - Multi-dimensional arrays are actually pretty simple. For each - dimension of the array, you add another [key] value to the end: - - <informalexample> - <programlisting role="php"> -$a[1] = $f; # one dimensional examples -$a["foo"] = $f; - -$a[1][0] = $f; # two dimensional -$a["foo"][2] = $f; # (you can mix numeric and associative indices) -$a[3]["bar"] = $f; # (you can mix numeric and associative indices) - -$a["foo"][4]["bar"][0] = $f; # four dimensional! - </programlisting> - </informalexample> - - <para> - You can "fill up" multi-dimensional arrays in many ways, but - the trickiest one to grok is how to use the <function>array</function> - command for associative arrays. These two snippets of code fill up - the one-dimensional array in the same way: - - <informalexample> - <programlisting role="php"> -# Example 1: - -$a["color"] = "red"; -$a["taste"] = "sweet"; -$a["shape"] = "round"; -$a["name"] = "apple"; -$a[3] = 4; - - -# Example 2: -$a = array( - "color" => "red", - "taste" => "sweet", - "shape" => "round", - "name" => "apple", - 3 => 4 -); - </programlisting> - </informalexample> - - <para> - The <function>array</function> function can be nested for - multi-dimensional arrays: - - <informalexample> - <programlisting role="php"> -&lt;? -$a = array( - "apple" => array( - "color" => "red", - "taste" => "sweet", - "shape" => "round" - ), - "orange" => array( - "color" => "orange", - "taste" => "sweet", - "shape" => "round" - ), - "banana" => array( - "color" => "yellow", - "taste" => "paste-y", - "shape" => "banana-shaped" - ) -); - -echo $a["apple"]["taste"]; # will output "sweet" -?> - </programlisting> - </informalexample> - - </sect2> - - </sect1> </chapter> -- 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

« previous php.dev (#5969) next »