Variable Scope

From: Date: Sat, 30 Aug 2003 14:18:00 +0000
Subject: Variable Scope
Groups: php.internals 
Request: Send a blank email to internals+get-4262@lists.php.net to get a copy of this message
Variable scope is mediocre at best. For instances: $array = array(1, 2, 3, 4, 5); for ($i = 0; $i < 5; $i++) { $num = $array[$i]; echo $num; for ($i = 0; $i < 5; $i++) { echo $num * $i; } } The inner loop $i doesn't mask the outer loop $i. Thus, the whole things gets screwed up.

« previous php.internals (#4262) next »