RE: [PHP-DEV] Lexical scoping
From: Christian Stoller Date: Tue, 28 Jan 2014 13:33:42 +0000 Subject: RE: [PHP-DEV] Lexical scoping References: 1 2 Groups: php.internals Request: Send a blank email to [email protected] to get a copy of this message
> > Regarding your example: > > > > foreach ($array as &$a) { > > $a = 3; > > } > > $a = null; // $a not a reference anymore. Problem solved :) > > > > > Problem not solved. You have just changed the last element of $array... > This is the exact problem that was to be avoided. >unset($a)
after the foreach solves the problem.
Thread (11 messages)
« previous | php.internals (#71669) | next » |
---|