what is the variable scope of a class member variable?
Posted: Wed Nov 16, 2005 5:09 pm
twigletmac | Please use
Is the variable $a at line 2 the same varialbe $a at line 4?
Which $a is used at line 7, the one at line 2 or the one at line 4?
Thanks.
Code: Select all
tags when posting PHP code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
What is the variable scope of a class member variable? Is it the same as the function variable or a script variable?
For example, foo.php:Code: Select all
1. <?
2. $a = 1;
3. class bar {
4. $a = 2;
5. function test() {
6. global $a;
7. $a = 3;
8. }
9. }
10. ?>Which $a is used at line 7, the one at line 2 or the one at line 4?
Thanks.