PDA

View Full Version : Variable scope within plugins


Dean C
12 Nov 2005, 19:49
I'm trying to debug one of my plugins and see why it's outputting an error. The obvious thing would be to output the variables and check they are all there right?

Try putting this in global_complete:


Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



Nothing is output. However, if you put this in there:



Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



It'll output 'test'. Am I missing something here ;)?

Andreas
12 Nov 2005, 19:52
Yes :)

You are missing that global_complete is within function print_output(), so $var will only be visible within this function - but not in moo(), even though you define it as global there.

Dean C
12 Nov 2005, 19:53
Ah of course - thanks! And congratulations on your new role ;)