SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Evangelist
    Join Date
    Oct 2000
    Posts
    430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    If I wish to 'include' a file of variables via a function call

    function SomeFunction($Variable){
    include("variablesfile");
    /*
    Perform set of tasks
    */
    }

    Are these variables only accessible by that function and are they destroyed after the function finishes? Or are they made available globally?

  2. #2
    SitePoint Wizard TWTCommish's Avatar
    Join Date
    Aug 1999
    Location
    Pittsburgh, PA, USA
    Posts
    3,910
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I believe they are only available globally if you declare them all as global. I could be wrong, but I'm pretty sure of that.

  3. #3
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    My guess is that the variables are local to the function only and will be destroyed at the end of the function.

    You can always write up a little test program to check.

  4. #4
    SitePoint Member
    Join Date
    Feb 2001
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    They are available only to the function. Maybe you could make the function return the values you are registering, or to first define the variable as global then give it a value.

  5. #5
    SitePoint Evangelist
    Join Date
    Oct 2000
    Posts
    430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cheers for your thoughts


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
  •