goba Sun Aug 19 13:03:33 2001 EDT
Modified files:
/phpdoc/en/language references.xml
Log:
. Using PEAR standars for function definition layout (WS only)
. Using <varname> for the foo function's name in all of the texts
. Crrecting one function call's missing brackets
Index: phpdoc/en/language/references.xml
diff -u phpdoc/en/language/references.xml:1.13 phpdoc/en/language/references.xml:1.14
--- phpdoc/en/language/references.xml:1.13 Sun Aug 19 07:09:17 2001
+++ phpdoc/en/language/references.xml Sun Aug 19 13:03:32 2001
@@ -1,5 +1,5 @@
<?xml encoding="iso-8859-1"?>
-<!-- $Revision: 1.13 $ -->
+<!-- $Revision: 1.14 $ -->
<chapter id="language.references">
<title>References Explained</title>
@@ -65,7 +65,8 @@
a variable in the calling scope reference to the same content. Example:
<informalexample>
<programlisting role="php">
-function foo (&$var) {
+function foo (&$var)
+{
$var++;
}
@@ -92,7 +93,8 @@
following construct won't do what you expect:
<informalexample>
<programlisting role="php">
-function foo (&$var) {
+function foo (&$var)
+{
$var =& $GLOBALS["baz"];
}
foo($bar);
@@ -100,12 +102,13 @@
</informalexample>
</para>
<simpara>
- What happens is that <varname>$var</varname> in foo will be bound
- with <varname>$bar</varname> in caller, but then it will be
+ What happens is that <varname>$var</varname> in
+ <varname>foo</varname> will be bound with
+ <varname>$bar</varname> in caller, but then it will be
re-bound with <varname>$GLOBALS["baz"]</varname>. There's no way
to bind <varname>$bar</varname> in the calling scope to something else
using the reference mechanism, since <varname>$bar</varname> is not
- available in the function foo (it is represented by
+ available in the function <varname>foo</varname> (it is represented by
<varname>$var</varname>, but <varname>$var</varname> has only
variable contents and not name-to-value binding in the calling
symbol table).
@@ -119,7 +122,8 @@
its arguments. The syntax is as follows:
<informalexample>
<programlisting role="php">
-function foo (&$var) {
+function foo (&$var)
+{
$var++;
}
@@ -175,7 +179,7 @@
$a = 5;
return $a;
}
-foo(bar);
+foo(bar());
foo($a = 5) // Expression, not variable
foo(5) // Constant, not variable
@@ -193,7 +197,8 @@
returning references, use this syntax:
<informalexample>
<programlisting role="php">
-function &find_var ($param) {
+function &find_var ($param)
+{
...code...
return $found_var;
}