goba Fri Dec 28 13:46:53 2001 EDT
Modified files:
/phpdoc/en/language types.xml
Log:
Eliminate all <link> stuff from CDATA sections, and moved DEV comments
out of example code. The manual pages with these examples were a huge
mess...
Index: phpdoc/en/language/types.xml
diff -u phpdoc/en/language/types.xml:1.69 phpdoc/en/language/types.xml:1.70
--- phpdoc/en/language/types.xml:1.69 Wed Dec 12 17:08:28 2001
+++ phpdoc/en/language/types.xml Fri Dec 28 13:46:53 2001
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.69 $ -->
+<!-- $Revision: 1.70 $ -->
<chapter id="language.types">
<title>Types</title>
@@ -172,12 +172,13 @@
<informalexample>
<programlisting role="php">
<![CDATA[
-if ($action == "show_version") { // == is an <link
linkend="language.operators">operator</link> which returns a <type>boolean</type>
+// == is an operator which returns a boolean
+if ($action == "show_version") {
echo "The version is 1.23";
}
// this is not necessary:
-if ($show_separators == true) {
+if ($show_separators == TRUE) {
echo "<hr>\n";
}
@@ -833,20 +834,22 @@
<programlisting role="php">
<![CDATA[
$fruits = array( 'strawberry' => 'red' , 'banana' => 'yellow' );
-echo "A banana is $fruits[banana]."; // note that this works differently
-outside string-quotes. See <link
-linkend="language.types.array.foo-bar"><literal>$foo[bar]</literal> outside
strings</link>
+
+// note that this works differently outside string-quotes.
+echo "A banana is $fruits[banana].";
+
echo "This square is $square->width meters broad.";
-echo "This square is $square->width00 centimeters broad."; // won't work,
- // for a solution, see the <link
linkend="language.types.string.parsing.complex">complex syntax</link>.
+// Won't work. For a solution, see the complex syntax.
+echo "This square is $square->width00 centimeters broad.";
+
+]]>
<!-- XXX this won't work:
echo "This square is $square->{width}00 centimeters broad.";
// XXX: php developers: it would be consequent to make this work.
// XXX: like the $obj->{expr} syntax outside a string works,
// XXX: analogously to the ${expr} syntax for variable var's.
-->
-]]>
</programlisting>
</informalexample>
<simpara>
@@ -876,19 +879,21 @@
echo "This is {$great}"; // works, outputs: This is fantastic
echo "This square is {$square->width}00 centimeters broad.";
echo "This works: {$arr[4][3]}";
-echo "This is wrong: {$arr[foo][3]}"; // for the same reason
- // as <link linkend="language.types.array.foo-bar">$foo[bar]</link
- > is wrong outside a string.
+
+// This is wrong for the same reason
+// as $foo[bar] is wrong outside a string.
+echo "This is wrong: {$arr[foo][3]}";
+
echo "You should do it this way: {$arr['foo'][3]}";
echo "You can even write {$obj->values[3]->name}";
echo "This is the value of the var named $name: {${$name}}";
-<!-- <xxx> maybe it's better to leave this out??
+]]>
+<!-- maybe it's better to leave this out??
// this works, but i disencourage its use, since this is NOT
// involving functions, rather than mere variables, arrays and objects.
$beer = 'Heineken';
echo "I'd like to have another {${ strrev('reeb') }}, hips";
- </xxx> -->
-]]>
+ -->
</programlisting>
</informalexample>
</sect4>
@@ -911,10 +916,10 @@
<example>
<title>Some string examples</title>
<programlisting role="php">
-<![CDATA[
<!-- TODO: either move these examples to a example section,
as with arrays, or distribute them under the applicable
sections. -->
+<![CDATA[
<?php
/* Assigning a string. */
$str = "This is a string";
@@ -1365,6 +1370,9 @@
, 0 => 12 // the value 10 will be overwritten by 12
);
+// empty array
+$empty = array();
+]]>
<!-- TODO example of
- mixed keys
- overwriting keys
@@ -1372,10 +1380,6 @@
- using vars/functions as key/values
- mixed skipping
-->
-
-// empty array
-$empty = array();
-]]>
</programlisting>
</example>
@@ -1412,14 +1416,15 @@
<example id="language.types.array.examples.changeloop">
<title>Collection</title>
<programlisting role="php">
-<link linkend="control-structures.foreach">foreach</link> ( $colors as $key => $color
) {
+<![CDATA[
+foreach ($colors as $key => $color) {
// won't work:
- //$color = <link linkend="function.strtoupper">strtoupper</link>($color);
+ //$color = strtoupper($color);
//works:
- $colors[$key] = <link linkend="function.strtoupper">strtoupper</link>($color);
+ $colors[$key] = strtoupper($color);
}
-<link linkend="function.print-r">print_r</link>($colors);
+print_r($colors);
/* output:
Array
@@ -1430,6 +1435,7 @@
[3] => YELLOW
)
*/
+]]>
</programlisting>
</example>
</para>
@@ -1438,8 +1444,9 @@
<example>
<title>One-based index</title>
<programlisting role="php">
+<![CDATA[
$firstquarter = array(1 => 'January', 'February', 'March');
-<link linkend="function.print-r">print_r</link>($firstquarter);
+print_r($firstquarter);
/* output:
Array
@@ -1448,20 +1455,23 @@
[2] => 'February'
[3] => 'March'
)
-*/
+*/
+]]>
</programlisting>
</example>
</para>
<example>
<title>Filling real array</title>
<programlisting role="php">
-// fill an array with all items from a <link linkend="ref.dir">directory</link>
-$handle = <link linkend="function.opendir">opendir</link>('.');
-while ($file = <link linkend="function.readdir">readdir</link>($handle))
+<![CDATA[
+// fill an array with all items from a directory
+$handle = opendir('.');
+while ($file = readdir($handle))
{
$files[] = $file;
}
-<link linkend="function.closedir">closedir</link>($handle);
+closedir($handle);
+]]>
</programlisting>
</example>
<para>
@@ -1472,8 +1482,10 @@
<example>
<title>Sorting array</title>
<programlisting role="php">
-<link linkend="function.sort">sort</link>($files);
-<link linkend="function.print-r">print_r</link>($files);
+<![CDATA[
+sort($files);
+print_r($files);
+]]>
</programlisting>
</example>
<para>
@@ -1484,23 +1496,24 @@
<example>
<title>Recursive and multi-dimensional arrays</title>
<programlisting role="php">
-$fruits = array ( "fruits" => array ( "a" => "orange"
- , "b" => "banana"
- , "c" => "apple"
+<![CDATA[
+$fruits = array ( "fruits" => array ( "a" => "orange"
+ , "b" => "banana"
+ , "c" => "apple"
)
- , "numbers" => array ( 1
+ , "numbers" => array ( 1
, 2
, 3
, 4
, 5
, 6
)
- , "holes" => array ( "first"
- , 5 => "second"
+ , "holes" => array ( "first"
+ , 5 => "second"
, "third"
)
);
-
+]]>
<!-- quite duplicate...
$a = array(
"apple" => array(
@@ -1720,7 +1733,8 @@
<informalexample>
<programlisting role="php">
-<?php
+<![CDATA[
+<?php
class foo
{
function do_foo()
@@ -1732,6 +1746,7 @@
$bar = new foo;
$bar->do_foo();
?>
+]]>
</programlisting>
</informalexample>
</para>