[PHP-DOC] cvs: phpdoc /en/language references.xml
colder Sat Feb 24 11:19:24 2007 UTC Modified files: /phpdoc/en/language references.xml Log: Fix #40610 (Undefined variables get defined when used with references) http://cvs.php.net/viewvc.cgi/phpdoc/en/language/references.xml?r1=1.46r2=1.47diff_format=u Index: phpdoc/en/language/references.xml diff -u phpdoc/en/language/references.xml:1.46 phpdoc/en/language/references.xml:1.47 --- phpdoc/en/language/references.xml:1.46 Fri Nov 18 16:20:48 2005 +++ phpdoc/en/language/references.xml Sat Feb 24 11:19:24 2007 @@ -1,5 +1,5 @@ ?xml version=1.0 encoding=iso-8859-1? -!-- $Revision: 1.46 $ -- +!-- $Revision: 1.47 $ -- chapter id=language.references titleReferences Explained/title @@ -49,6 +49,32 @@ This is valid also for arrays passed by value to functions. /para /note + note +para +If you assign, pass or return an undefined variable by reference, +it will get created. + example + titleUsing references with undefined variables/title + programlisting role=php +![CDATA[ +?php +function foo($var) { } + +foo($a); // $a is created and assigned to null + +$b = array(); +foo($b['b']); +var_dump(array_key_exists('b', $b)); // bool(true) + +$c = new StdClass; +foo($c-d); +var_dump(property_exists($c, 'd')); // bool(true) +? +]] + /programlisting + /example +/para + /note para The same syntax can be used with functions, that return references, and with literalnew/literal operator (in PHP 4.0.4 and later):
[PHP-DOC] cvs: phpdoc /en/language references.xml
colder Sat Feb 24 20:14:49 2007 UTC Modified files: /phpdoc/en/language references.xml Log: Remove bogous warning http://cvs.php.net/viewvc.cgi/phpdoc/en/language/references.xml?r1=1.47r2=1.48diff_format=u Index: phpdoc/en/language/references.xml diff -u phpdoc/en/language/references.xml:1.47 phpdoc/en/language/references.xml:1.48 --- phpdoc/en/language/references.xml:1.47 Sat Feb 24 11:19:24 2007 +++ phpdoc/en/language/references.xml Sat Feb 24 20:14:49 2007 @@ -1,5 +1,5 @@ ?xml version=1.0 encoding=iso-8859-1? -!-- $Revision: 1.47 $ -- +!-- $Revision: 1.48 $ -- chapter id=language.references titleReferences Explained/title @@ -168,32 +168,6 @@ /example /para /note - warning -para - Complex arrays are sometimes rather copied than referenced. Thus following - example will not work as expected. - example - titleReferences with complex arrays/title - programlisting role=php -![CDATA[ -?php -$top = array( -'A' = array(), -'B' = array( -'B_b' = array(), -), -); - -$top['A']['parent'] = $top; -$top['B']['parent'] = $top; -$top['B']['B_b']['data'] = 'test'; -print_r($top['A']['parent']['B']['B_b']); // array() -? -]] - /programlisting - /example -/para - /warning para The second thing references do is to pass variables by-reference. This is done by making a local variable in a function and
[PHP-DOC] cvs: phpdoc /en/language references.xml
vrana Fri Nov 18 11:20:49 2005 EDT Modified files: /phpdoc/en/language references.xml Log: = new produces E_STRICT since PHP 5 http://cvs.php.net/diff.php/phpdoc/en/language/references.xml?r1=1.45r2=1.46ty=u Index: phpdoc/en/language/references.xml diff -u phpdoc/en/language/references.xml:1.45 phpdoc/en/language/references.xml:1.46 --- phpdoc/en/language/references.xml:1.45 Fri Sep 16 19:01:50 2005 +++ phpdoc/en/language/references.xml Fri Nov 18 11:20:48 2005 @@ -1,5 +1,5 @@ ?xml version=1.0 encoding=iso-8859-1? -!-- $Revision: 1.45 $ -- +!-- $Revision: 1.46 $ -- chapter id=language.references titleReferences Explained/title @@ -60,9 +60,12 @@ $foo = find_var($bar); ? ]] -/programlisting + /programlisting /informalexample -/para +Since PHP 5, link linkend=language.oop5.basic.newnew/link return +reference automatically so using literal=amp;/literal in this +context is deprecated and produces E_STRICT level message. + /para note para Not using the literalamp;/literal operator causes a copy of the
[PHP-DOC] cvs: phpdoc /en/language references.xml
vrana Fri Sep 16 19:01:53 2005 EDT Modified files: /phpdoc/en/language references.xml Log: Wrong references are fatal since 5.0.5, not 5.1.0 http://cvs.php.net/diff.php/phpdoc/en/language/references.xml?r1=1.44r2=1.45ty=u Index: phpdoc/en/language/references.xml diff -u phpdoc/en/language/references.xml:1.44 phpdoc/en/language/references.xml:1.45 --- phpdoc/en/language/references.xml:1.44 Mon Jul 25 09:00:01 2005 +++ phpdoc/en/language/references.xml Fri Sep 16 19:01:50 2005 @@ -1,5 +1,5 @@ ?xml version=1.0 encoding=iso-8859-1? -!-- $Revision: 1.44 $ -- +!-- $Revision: 1.45 $ -- chapter id=language.references titleReferences Explained/title @@ -307,7 +307,7 @@ $a = 5; return $a; } -foo(bar()); // Produces fatal error since PHP 5.1.0 +foo(bar()); // Produces fatal error since PHP 5.0.5 foo($a = 5); // Expression, not variable foo(5); // Produces fatal error
[PHP-DOC] cvs: phpdoc /en/language references.xml
vrana Mon Jul 25 09:00:06 2005 EDT Modified files: /phpdoc/en/language references.xml Log: E_NOTICE is issued with returning non-references in new versions http://cvs.php.net/diff.php/phpdoc/en/language/references.xml?r1=1.43r2=1.44ty=u Index: phpdoc/en/language/references.xml diff -u phpdoc/en/language/references.xml:1.43 phpdoc/en/language/references.xml:1.44 --- phpdoc/en/language/references.xml:1.43 Thu Jul 14 05:16:30 2005 +++ phpdoc/en/language/references.xml Mon Jul 25 09:00:01 2005 @@ -1,5 +1,5 @@ ?xml version=1.0 encoding=iso-8859-1? -!-- $Revision: 1.43 $ -- +!-- $Revision: 1.44 $ -- chapter id=language.references titleReferences Explained/title @@ -364,6 +364,9 @@ work as you are attempting to return the result of an emphasisexpression/emphasis, and not a variable, by reference. You can only return variables by reference from a function - nothing else. + constantE_NOTICE/constant error is issued since PHP 4.4.0 and PHP + 5.1.0 if the code tries to return a dynamic expression or a result of the + literalnew/literal operator. /simpara /note /sect1
[PHP-DOC] cvs: phpdoc /en/language references.xml
jon Mon Jul 4 17:01:58 2005 EDT Modified files: /phpdoc/en/language references.xml Log: Break this comma splice by using a semicolon to join the two independent clauses. The second two lines of the diff are the result of rewrapping the text for column width. http://cvs.php.net/diff.php/phpdoc/en/language/references.xml?r1=1.39r2=1.40ty=u Index: phpdoc/en/language/references.xml diff -u phpdoc/en/language/references.xml:1.39 phpdoc/en/language/references.xml:1.40 --- phpdoc/en/language/references.xml:1.39 Fri Apr 15 10:19:52 2005 +++ phpdoc/en/language/references.xml Mon Jul 4 17:01:56 2005 @@ -1,5 +1,5 @@ ?xml version=1.0 encoding=iso-8859-1? -!-- $Revision: 1.39 $ -- +!-- $Revision: 1.40 $ -- chapter id=language.references titleReferences Explained/title @@ -7,9 +7,9 @@ titleWhat References Are/title simpara References in PHP are a means to access the same variable content -by different names. They are not like C pointers, they are symbol -table aliases. Note that in PHP, variable name and variable content -are different, so the same content can have different names. +by different names. They are not like C pointers; instead, they are +symbol table aliases. Note that in PHP, variable name and variable +content are different, so the same content can have different names. The most close analogy is with Unix filenames and files - variable names are directory entries, while variable contents is the file itself. References can be thought of as hardlinking in
[PHP-DOC] cvs: phpdoc /en/language references.xml
vrana Fri Apr 15 10:19:53 2005 EDT Modified files: /phpdoc/en/language references.xml Log: $a and $b point to the same content, not variable (spotted by Sebastian Mendel) http://cvs.php.net/diff.php/phpdoc/en/language/references.xml?r1=1.38r2=1.39ty=u Index: phpdoc/en/language/references.xml diff -u phpdoc/en/language/references.xml:1.38 phpdoc/en/language/references.xml:1.39 --- phpdoc/en/language/references.xml:1.38 Thu Apr 7 10:26:42 2005 +++ phpdoc/en/language/references.xml Fri Apr 15 10:19:52 2005 @@ -1,5 +1,5 @@ ?xml version=1.0 encoding=iso-8859-1? -!-- $Revision: 1.38 $ -- +!-- $Revision: 1.39 $ -- chapter id=language.references titleReferences Explained/title @@ -32,7 +32,7 @@ /programlisting /informalexample it means that varname$a/varname and varname$b/varname -point to the same variable. +point to the same content. note para varname$a/varname and varname$b/varname are completely
[PHP-DOC] cvs: phpdoc /en/language references.xml
vrana Thu Apr 7 10:26:43 2005 EDT Modified files: /phpdoc/en/language references.xml Log: 'function ' is optional with methods (bug #29877) http://cvs.php.net/diff.php/phpdoc/en/language/references.xml?r1=1.37r2=1.38ty=u Index: phpdoc/en/language/references.xml diff -u phpdoc/en/language/references.xml:1.37 phpdoc/en/language/references.xml:1.38 --- phpdoc/en/language/references.xml:1.37 Sun Aug 8 13:26:59 2004 +++ phpdoc/en/language/references.xml Thu Apr 7 10:26:42 2005 @@ -1,5 +1,5 @@ ?xml version=1.0 encoding=iso-8859-1? -!-- $Revision: 1.37 $ -- +!-- $Revision: 1.38 $ -- chapter id=language.references titleReferences Explained/title @@ -350,6 +350,8 @@ return by-reference, not a copy as usual, and to indicate that reference binding, rather than usual assignment, should be done for varname$foo/varname. + literalamp;/literal by function definition is optional in + link linkend=keyword.classclass/link methods. /simpara /note /sect1
[PHP-DOC] cvs: phpdoc /en/language references.xml
seanSun Aug 8 13:27:00 2004 EDT Modified files: /phpdoc/en/language references.xml Log: cleanup (grammar) http://cvs.php.net/diff.php/phpdoc/en/language/references.xml?r1=1.36r2=1.37ty=u Index: phpdoc/en/language/references.xml diff -u phpdoc/en/language/references.xml:1.36 phpdoc/en/language/references.xml:1.37 --- phpdoc/en/language/references.xml:1.36 Sat Aug 7 06:06:24 2004 +++ phpdoc/en/language/references.xml Sun Aug 8 13:26:59 2004 @@ -1,5 +1,5 @@ ?xml version=1.0 encoding=iso-8859-1? -!-- $Revision: 1.36 $ -- +!-- $Revision: 1.37 $ -- chapter id=language.references titleReferences Explained/title @@ -83,9 +83,9 @@ /note warning para - If you assign reference to a variable stated as literalglobal/literal - inside function, the reference will be visible only inside the function. - You can avoid it by using varname$GLOBALS/varname array. + If you assign a reference to a variable declared literalglobal/literal + inside a function, the reference will be visible only inside the function. + You can avoid this by using the varname$GLOBALS/varname array. example titleReferencing global variables inside function/title programlisting role=php @@ -119,9 +119,9 @@ /warning note para - If you assign a value to variable with references in the link + If you assign a value to a variable with references in a link linkend=control-structures.foreachforeach/link statement, - references are modified too. + the references are modified too. example titleReferences and foreach statement/title programlisting role=php
[PHP-DOC] cvs: phpdoc /en/language references.xml
vrana Sat Aug 7 06:06:24 2004 EDT Modified files: /phpdoc/en/language references.xml Log: References and foreach (bug #24118) http://cvs.php.net/diff.php/phpdoc/en/language/references.xml?r1=1.35r2=1.36ty=u Index: phpdoc/en/language/references.xml diff -u phpdoc/en/language/references.xml:1.35 phpdoc/en/language/references.xml:1.36 --- phpdoc/en/language/references.xml:1.35 Fri Aug 6 17:45:13 2004 +++ phpdoc/en/language/references.xml Sat Aug 7 06:06:24 2004 @@ -1,5 +1,5 @@ ?xml version=1.0 encoding=iso-8859-1? -!-- $Revision: 1.35 $ -- +!-- $Revision: 1.36 $ -- chapter id=language.references titleReferences Explained/title @@ -117,6 +117,28 @@ to literal$var/literal only changes the local variable's reference. /para /warning + note +para + If you assign a value to variable with references in the link + linkend=control-structures.foreachforeach/link statement, + references are modified too. + example + titleReferences and foreach statement/title + programlisting role=php +![CDATA[ +?php +$ref = 0; +$row = $ref; +foreach (array(1, 2, 3) as $row) { +// do something +} +echo $ref; // 3 - last element of the iterated array +? +]] + /programlisting + /example +/para + /note warning para Complex arrays are sometimes rather copied than referenced. Thus following
[PHP-DOC] cvs: phpdoc /en/language references.xml
vrana Fri Aug 6 05:00:04 2004 EDT Modified files: /phpdoc/en/language references.xml Log: WS http://cvs.php.net/diff.php/phpdoc/en/language/references.xml?r1=1.32r2=1.33ty=u Index: phpdoc/en/language/references.xml diff -u phpdoc/en/language/references.xml:1.32 phpdoc/en/language/references.xml:1.33 --- phpdoc/en/language/references.xml:1.32 Thu Aug 5 11:05:59 2004 +++ phpdoc/en/language/references.xml Fri Aug 6 05:00:04 2004 @@ -1,5 +1,5 @@ ?xml version=1.0 encoding=iso-8859-1? -!-- $Revision: 1.32 $ -- +!-- $Revision: 1.33 $ -- chapter id=language.references titleReferences Explained/title @@ -26,7 +26,7 @@ programlisting role=php ![CDATA[ ?php -$a = $b +$a = $b; ? ]] /programlisting @@ -57,7 +57,7 @@ ![CDATA[ ?php $bar = new fooclass(); -$foo = find_var ($bar); +$foo = find_var($bar); ? ]] /programlisting @@ -151,13 +151,13 @@ programlisting role=php ![CDATA[ ?php -function foo ($var) +function foo($var) { $var++; } $a=5; -foo ($a); +foo($a); ? ]] /programlisting @@ -183,7 +183,7 @@ programlisting role=php ![CDATA[ ?php -function foo ($var) +function foo($var) { $var = $GLOBALS[baz]; } @@ -216,13 +216,13 @@ programlisting role=php ![CDATA[ ?php -function foo ($var) +function foo($var) { $var++; } $a=5; -foo ($a); +foo($a); // $a is 6 here ? ]] @@ -303,13 +303,13 @@ programlisting role=php ![CDATA[ ?php -function find_var ($param) +function find_var($param) { /* ...code... */ return $found_var; } -$foo = find_var ($bar); +$foo = find_var($bar); $foo-x = 2; ? ]] @@ -342,7 +342,7 @@ ?php $a = 1; $b = $a; -unset ($a); +unset($a); ? ]] /programlisting
[PHP-DOC] cvs: phpdoc /en/language references.xml
vrana Fri Aug 6 17:39:40 2004 EDT Modified files: /phpdoc/en/language references.xml Log: See also http://cvs.php.net/diff.php/phpdoc/en/language/references.xml?r1=1.33r2=1.34ty=u Index: phpdoc/en/language/references.xml diff -u phpdoc/en/language/references.xml:1.33 phpdoc/en/language/references.xml:1.34 --- phpdoc/en/language/references.xml:1.33 Fri Aug 6 05:00:04 2004 +++ phpdoc/en/language/references.xml Fri Aug 6 17:39:39 2004 @@ -1,5 +1,5 @@ ?xml version=1.0 encoding=iso-8859-1? -!-- $Revision: 1.33 $ -- +!-- $Revision: 1.34 $ -- chapter id=language.references titleReferences Explained/title @@ -204,6 +204,8 @@ varname$var/varname, but varname$var/varname has only variable contents and not name-to-value binding in the calling symbol table). +You can use link linkend=language.references.returnreturning +references/link to reference variable selected by the function. /simpara /sect1
[PHP-DOC] cvs: phpdoc /en/language references.xml
seanFri Aug 6 17:45:13 2004 EDT Modified files: /phpdoc/en/language references.xml Log: grammar http://cvs.php.net/diff.php/phpdoc/en/language/references.xml?r1=1.34r2=1.35ty=u Index: phpdoc/en/language/references.xml diff -u phpdoc/en/language/references.xml:1.34 phpdoc/en/language/references.xml:1.35 --- phpdoc/en/language/references.xml:1.34 Fri Aug 6 17:39:39 2004 +++ phpdoc/en/language/references.xml Fri Aug 6 17:45:13 2004 @@ -1,5 +1,5 @@ ?xml version=1.0 encoding=iso-8859-1? -!-- $Revision: 1.34 $ -- +!-- $Revision: 1.35 $ -- chapter id=language.references titleReferences Explained/title @@ -205,7 +205,7 @@ variable contents and not name-to-value binding in the calling symbol table). You can use link linkend=language.references.returnreturning -references/link to reference variable selected by the function. +references/link to reference variables selected by the function. /simpara /sect1
[PHP-DOC] cvs: phpdoc /en/language references.xml
bagileviThu Aug 5 11:05:59 2004 EDT Modified files: /phpdoc/en/language references.xml Log: fixed example: referencing globals http://cvs.php.net/diff.php/phpdoc/en/language/references.xml?r1=1.31r2=1.32ty=u Index: phpdoc/en/language/references.xml diff -u phpdoc/en/language/references.xml:1.31 phpdoc/en/language/references.xml:1.32 --- phpdoc/en/language/references.xml:1.31 Mon Jul 26 16:53:56 2004 +++ phpdoc/en/language/references.xml Thu Aug 5 11:05:59 2004 @@ -1,5 +1,5 @@ ?xml version=1.0 encoding=iso-8859-1? -!-- $Revision: 1.31 $ -- +!-- $Revision: 1.32 $ -- chapter id=language.references titleReferences Explained/title @@ -98,9 +98,9 @@ { global $var1, $var2; if (!$use_globals) { -$var1 = $var2; // visible only inside the function +$var2 = $var1; // visible only inside the function } else { -$GLOBALS[var1] = $var2; // visible also in global context +$GLOBALS[var2] = $var1; // visible also in global context } }
[PHP-DOC] cvs: phpdoc /en/language references.xml
vrana Mon Jul 26 11:16:26 2004 EDT Modified files: /phpdoc/en/language references.xml Log: Arrays with references (bug #20993) http://cvs.php.net/diff.php/phpdoc/en/language/references.xml?r1=1.27r2=1.28ty=u Index: phpdoc/en/language/references.xml diff -u phpdoc/en/language/references.xml:1.27 phpdoc/en/language/references.xml:1.28 --- phpdoc/en/language/references.xml:1.27 Sun Dec 21 10:37:29 2003 +++ phpdoc/en/language/references.xml Mon Jul 26 11:16:26 2004 @@ -1,5 +1,5 @@ ?xml version=1.0 encoding=iso-8859-1? -!-- $Revision: 1.27 $ -- +!-- $Revision: 1.28 $ -- chapter id=language.references titleReferences Explained/title @@ -43,6 +43,12 @@ /para /note /para + note +para + If array with references is copied, its values are not dereferenced. + This is valid also for arrays passed by value to functions. +/para + /note para The same syntax can be used with functions, that return references, and with literalnew/literal operator (in PHP 4.0.4 and later):
[PHP-DOC] cvs: phpdoc /en/language references.xml
vrana Mon Jul 26 16:38:58 2004 EDT Modified files: /phpdoc/en/language references.xml Log: Explain this a bit http://cvs.php.net/diff.php/phpdoc/en/language/references.xml?r1=1.29r2=1.30ty=u Index: phpdoc/en/language/references.xml diff -u phpdoc/en/language/references.xml:1.29 phpdoc/en/language/references.xml:1.30 --- phpdoc/en/language/references.xml:1.29 Mon Jul 26 11:55:09 2004 +++ phpdoc/en/language/references.xml Mon Jul 26 16:38:58 2004 @@ -1,5 +1,5 @@ ?xml version=1.0 encoding=iso-8859-1? -!-- $Revision: 1.29 $ -- +!-- $Revision: 1.30 $ -- chapter id=language.references titleReferences Explained/title @@ -112,6 +112,9 @@ ]] /programlisting /example + Think about literalglobal $var;/literal as a shortcut to literal$var + =amp; $GLOBALS['var'];/literal. Thus assigning other reference + to literal$var/literal only changes the local variable's reference. /para /warning para
[PHP-DOC] cvs: phpdoc /en/language references.xml
vrana Mon Jul 26 16:53:57 2004 EDT Modified files: /phpdoc/en/language references.xml Log: References with complex arrays (bug #17959) http://cvs.php.net/diff.php/phpdoc/en/language/references.xml?r1=1.30r2=1.31ty=u Index: phpdoc/en/language/references.xml diff -u phpdoc/en/language/references.xml:1.30 phpdoc/en/language/references.xml:1.31 --- phpdoc/en/language/references.xml:1.30 Mon Jul 26 16:38:58 2004 +++ phpdoc/en/language/references.xml Mon Jul 26 16:53:56 2004 @@ -1,5 +1,5 @@ ?xml version=1.0 encoding=iso-8859-1? -!-- $Revision: 1.30 $ -- +!-- $Revision: 1.31 $ -- chapter id=language.references titleReferences Explained/title @@ -115,6 +115,32 @@ Think about literalglobal $var;/literal as a shortcut to literal$var =amp; $GLOBALS['var'];/literal. Thus assigning other reference to literal$var/literal only changes the local variable's reference. +/para + /warning + warning +para + Complex arrays are sometimes rather copied than referenced. Thus following + example will not work as expected. + example + titleReferences with complex arrays/title + programlisting role=php +![CDATA[ +?php +$top = array( +'A' = array(), +'B' = array( +'B_b' = array(), +), +); + +$top['A']['parent'] = $top; +$top['B']['parent'] = $top; +$top['B']['B_b']['data'] = 'test'; +print_r($top['A']['parent']['B']['B_b']); // array() +? +]] + /programlisting + /example /para /warning para
[PHP-DOC] cvs: phpdoc /en/language references.xml
ae Sun Dec 21 10:37:29 2003 EDT Modified files: /phpdoc/en/language references.xml Log: s/TAB/spaces Index: phpdoc/en/language/references.xml diff -u phpdoc/en/language/references.xml:1.26 phpdoc/en/language/references.xml:1.27 --- phpdoc/en/language/references.xml:1.26 Thu Dec 11 10:41:58 2003 +++ phpdoc/en/language/references.xml Sun Dec 21 10:37:29 2003 @@ -1,5 +1,5 @@ ?xml version=1.0 encoding=iso-8859-1? -!-- $Revision: 1.26 $ -- +!-- $Revision: 1.27 $ -- chapter id=language.references titleReferences Explained/title @@ -221,7 +221,7 @@ ]] /programlisting /informalexample - These requirements are for PHP 4.0.4 and later. +These requirements are for PHP 4.0.4 and later. /para /sect1 @@ -242,7 +242,7 @@ } $foo = find_var ($bar); -$foo-x = 2; +$foo-x = 2; ? ]] /programlisting
[PHP-DOC] cvs: phpdoc /en/language references.xml
jan Wed Dec 12 16:15:37 2001 EDT Modified files: /phpdoc/en/language references.xml Log: fix for #11719. clearifyed references and copies on objects. Index: phpdoc/en/language/references.xml diff -u phpdoc/en/language/references.xml:1.20 phpdoc/en/language/references.xml:1.21 --- phpdoc/en/language/references.xml:1.20 Wed Dec 12 15:47:39 2001 +++ phpdoc/en/language/references.xml Wed Dec 12 16:15:37 2001 @@ -1,5 +1,5 @@ ?xml version=1.0 encoding=iso-8859-1? -!-- $Revision: 1.20 $ -- +!-- $Revision: 1.21 $ -- chapter id=language.references titleReferences Explained/title @@ -55,12 +55,14 @@ /para note para - Unless you use the syntax above, the result of - literal$bar = new fooclass()/literal will not be the same - variable as literal$this/literal in the constructor, meaning - that if you have used reference to literal$this/literal in - the constructor, you should use reference assignment, or you get - two different objects. + Not using the literal/literal operator causes a copy of + the object. If you use literal$this/literal in the class + it will operate on the current instance of the class. The + assignment without literal /literalwill copy the instance + (i.e. the object) and literal$this/literal will operate on + the copy, which is not always favoured. Mostly you want to have + a single instance to work with, due to performace and memory + consumption issues. /para /note para
[PHP-DOC] cvs: phpdoc /en/language references.xml
jimwWed Dec 12 16:29:56 2001 EDT Modified files: /phpdoc/en/language references.xml Log: - amp;, tighten the wording a bit Index: phpdoc/en/language/references.xml diff -u phpdoc/en/language/references.xml:1.21 phpdoc/en/language/references.xml:1.22 --- phpdoc/en/language/references.xml:1.21 Wed Dec 12 16:15:37 2001 +++ phpdoc/en/language/references.xml Wed Dec 12 16:29:56 2001 @@ -1,5 +1,5 @@ ?xml version=1.0 encoding=iso-8859-1? -!-- $Revision: 1.21 $ -- +!-- $Revision: 1.22 $ -- chapter id=language.references titleReferences Explained/title @@ -55,14 +55,13 @@ /para note para - Not using the literal/literal operator causes a copy of - the object. If you use literal$this/literal in the class - it will operate on the current instance of the class. The - assignment without literal /literalwill copy the instance - (i.e. the object) and literal$this/literal will operate on - the copy, which is not always favoured. Mostly you want to have - a single instance to work with, due to performace and memory - consumption issues. + Not using the literalamp;/literal operator causes a copy of the + object to be made. If you use literal$this/literal in the class it + will operate on the current instance of the class. The assignment without + literalamp;/literal will copy the instance (i.e. the object) and + literal$this/literal will operate on the copy, which is not always + what is desired. Usually you want to have a single instance to work with, + due to performance and memory consumption issues. /para /note para
[PHP-DOC] cvs: phpdoc /en/language references.xml
gobaMon Aug 20 09:58:08 2001 EDT Modified files: /phpdoc/en/language references.xml Log: More WS FIXES. People just don't seem to understand that we use four spaces for identation Gosh... Index: phpdoc/en/language/references.xml diff -u phpdoc/en/language/references.xml:1.14 phpdoc/en/language/references.xml:1.15 --- phpdoc/en/language/references.xml:1.14 Sun Aug 19 13:03:32 2001 +++ phpdoc/en/language/references.xml Mon Aug 20 09:58:08 2001 @@ -1,5 +1,5 @@ ?xml encoding=iso-8859-1? -!-- $Revision: 1.14 $ -- +!-- $Revision: 1.15 $ -- chapter id=language.references titleReferences Explained/title @@ -156,8 +156,8 @@ programlisting role=php function amp;bar() { - $a = 5; - return $a; +$a = 5; +return $a; } foo(bar()); /programlisting @@ -176,8 +176,8 @@ programlisting role=php function bar() // Note the missing amp; { -$a = 5; -return $a; +$a = 5; +return $a; } foo(bar());
[PHP-DOC] cvs: phpdoc /en/language references.xml
mj Wed Jul 11 04:41:49 2001 EDT Modified files: /phpdoc/en/language references.xml Log: Typo Index: phpdoc/en/language/references.xml diff -u phpdoc/en/language/references.xml:1.10 phpdoc/en/language/references.xml:1.11 --- phpdoc/en/language/references.xml:1.10 Tue Jul 10 15:37:15 2001 +++ phpdoc/en/language/references.xml Wed Jul 11 04:41:49 2001 @@ -114,7 +114,7 @@ titlePassing by Reference/title para You can pass variable to function by reference, so that function could modify - its arguments. The sytax is as follows: + its arguments. The syntax is as follows: informalexample programlisting role=php function foo (amp;$var) {