note 82150 added to language.operators.increment
| From: | pov at fingerprint dot fr | Date: | Fri, 28 Mar 2008 20:15:36 +0000 |
| Subject: | note 82150 added to language.operators.increment | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-137690@lists.php.net to get a copy of this message | ||
In reply to Anonymous :
What is strange is that you didn't get an error : ++$var is an expression and can't
therefore not be referenced.
Now, if you suppose an implicit assignment to an invisible variable, your code becomes :
<?php
$var = 1;
$plus_plus_var = ++$var;
change($plus_plus_var);
echo "var=$var";
?>
Written as such, change clearly acts on $plus_plus_var, not on $var. So PHP5 got right, and
it's not a "strange behaviour", it's only a solved bug.
Anyway, it's always a bad idea to pass anything other than a variable as a by-reference
parameter...
----
Server IP: 217.174.223.124
Probable Submitter: 212.99.15.251
----
Manual Page -- http://www.php.net/manual/en/language.operators.increment.php
Edit -- https://master.php.net/note/edit/82150
Del: integrated -- https://master.php.net/note/delete/82150/integrated
Del: useless -- https://master.php.net/note/delete/82150/useless
Del: bad code -- https://master.php.net/note/delete/82150/bad+code
Del: spam -- https://master.php.net/note/delete/82150/spam
Del: non-english -- https://master.php.net/note/delete/82150/non-english
Del: in docs -- https://master.php.net/note/delete/82150/in+docs
Del: other reasons-- https://master.php.net/note/delete/82150
Reject -- https://master.php.net/note/reject/82150
Search -- https://master.php.net/manage/user-notes.php