svn: /phpdoc/en/trunk/language/ variables.xml

From: Date: Sun, 09 Aug 2015 01:14:37 +0000
Subject: svn: /phpdoc/en/trunk/language/ variables.xml
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-13521@lists.php.net to get a copy of this message
aharvey Sun, 09 Aug 2015 01:14:37 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=337336 Log: Remove ambiguous variable property examples. Changed paths: U phpdoc/en/trunk/language/variables.xml Modified: phpdoc/en/trunk/language/variables.xml =================================================================== --- phpdoc/en/trunk/language/variables.xml 2015-08-09 01:14:33 UTC (rev 337335) +++ phpdoc/en/trunk/language/variables.xml 2015-08-09 01:14:37 UTC (rev 337336) @@ -736,15 +736,25 @@ </simpara> <simpara> - Class properties may also be accessed using variable property - names. The variable property name will be resolved within the - scope from which the call is made. For instance, if you have an - expression such as <varname>$foo->$bar</varname>, then the local - scope will be examined for <varname>$bar</varname> and its value - will be used as the name of the property - of <varname>$foo</varname>. This is also true - if <varname>$bar</varname> is an array access. + Class properties may also be accessed using variable property names. The + variable property name will be resolved within the scope from which the + call is made. For instance, if you have an expression such as + <varname>$foo->$bar</varname>, then the local scope will be examined for + <varname>$bar</varname> and its value will be used as the name of the + property of <varname>$foo</varname>. This is also true if + <varname>$bar</varname> is an array access. </simpara> + + <caution> + <simpara> + Further dereferencing a variable property that is an array has different + semantics between PHP 5 and PHP 7. The + <link linkend="migration70.incompatible.variable-handling.indirect">PHP 7.0 migration guide</link> + includes further details on the types of expressions that have changed, + and how to place curly braces to avoid ambiguity. + </simpara> + </caution> + <simpara> Curly braces may also be used, to clearly delimit the property name. They are most useful when accessing values within a property that @@ -770,15 +780,14 @@ $bar = 'bar'; $baz = array('foo', 'bar', 'baz', 'quux'); echo $foo->$bar . "\n"; -echo $foo->$baz[1] . "\n"; +echo $foo->{$baz[1]} . "\n"; $start = 'b'; $end = 'ar'; echo $foo->{$start . $end} . "\n"; $arr = 'arr'; -echo $foo->$arr[1] . "\n"; -echo $foo->{$arr}[1] . "\n"; +echo $foo->{$arr[1]} . "\n"; ?> ]]> @@ -789,7 +798,6 @@ I am bar. I am bar. I am r. -I am B. </screen> </example> </para>

« previous php.doc.cvs (#13521) next »