Results 1 to 3 of 3

Thread: Make variable available inside function

  1. #1

    Thread Starter
    Frenzied Member StrangerInBeijing's Avatar
    Join Date
    Mar 2005
    Location
    Not in Beijing
    Posts
    1,666

    Resolved Make variable available inside function

    I declare and set a variable ($level) on each and every page.

    of course this variable is available in all my included files, so that is fine.

    but just now i start including files with functions inside, and realized (after hour or two scratching my head) that such variables are not available inside my functions.

    is there other ways than actually passing this variable to my functions asan argumetn to make it available in there, because this method feel pretty clumpsy to me.

    cheers
    Last edited by StrangerInBeijing; Apr 1st, 2008 at 12:22 AM.

  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Make variable available inside function

    PHP Code:
    function myfunc()
    {
      global 
    $level;

      
    // ...


  3. #3

    Thread Starter
    Frenzied Member StrangerInBeijing's Avatar
    Join Date
    Mar 2005
    Location
    Not in Beijing
    Posts
    1,666

    Re: Make variable available inside function

    Strange I can swear I tried that earlier and it did not work.

    Anyhow, that just do the job. Thanks!

Posting Permissions

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



Click Here to Expand Forum to Full Width