PDA

View Full Version : Passing variables to functions



city_coder
05-26-2008, 05:54 PM
Hi guys, this is probably gona sound so tedious to you lot but im stuck

Iv got quite a few different functions that need to access variables that are all declared outside the functions(in the main section of the code). how do i go about those functions getting to those "global" variables without each function needing to be told im refering to the global variables here??

I would like to avoid having to pass them to the function aswell cos that obviously means putting them in an array to pass them back and then "unpacking" it to be used by each other function.

anything would be great

boogyman
05-27-2008, 01:59 PM
if the variables will stay the same, you can define a constant.



define("FOO", "bar");



I would like to avoid having to pass them to the function aswell cos that obviously means putting them in an array to pass them back and then "unpacking" it to be used by each other function.

or just assign another argument to the function?