Results 1 to 2 of 2

Thread: Passing variables to functions

  1. #1
    Join Date
    Feb 2008
    Location
    Coventry
    Posts
    103
    Thanks
    5
    Thanked 8 Times in 8 Posts

    Question Passing variables to functions

    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
    The important thing is not to stop questioning. Curiosity has its own reason for existing.

  2. #2
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    if the variables will stay the same, you can define a constant.

    PHP Code:
    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?

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •