note 11623 modified in Variable variables by ronabop

From: Date: Mon, 05 Mar 2001 01:34:19 +0000
Subject: note 11623 modified in Variable variables by ronabop
Groups: php.notes 
Request: Send a blank email to php-notes+get-11873@lists.php.net to get a copy of this message
This manual never seems to mention how scoping applies to variable variables. From what I can tell, variable variables are scoped to the nearest enclosing function (not to the nearest enclosing block, thankfully). function test() { do { $varname = 'text'; $$varname = 'testing 1,2,3'; while(0); print $text; } will give you 'testing 1,2,3'. This may be confusing to people who are used to stricter scoping rules. http://www.php.net/manual/variable-variables.php

« previous php.notes (#11873) next »