Understanding variable scopes in php

dapgido

New Member
\[code\]echo "Point1, a=".$a."\n";echo "Point1, b=".$b."\n";if(1<2) { $a = 6; $b['link'] = "here"; echo "Point2, a=".$a."\n"; echo "Point2, b[link]=".$b['link']."\n"; }echo "Point3, a=".$a."\n";echo "Point3, b[link]=".$b['link']."\n";\[/code\]Why does the above code print out the following?\[code\]Point1, a=Point1, b=Point2, a=6Point2, b[link]=herePoint3, a=6Point3, b[link]=here\[/code\]In my understanding, the scope of $a and $b should end within the curly braces { }!
 
Back
Top