SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Evangelist Jhorra's Avatar
    Join Date
    Sep 2004
    Location
    Phoenix, Az
    Posts
    551
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problem with include reading a variable

    I have my page layout split into a header and footer include. In determining whether to show a login or links, I check a logged in variable on the header include. On one of my pages because I may need to redirect so I don't include them on the main page. I call code from inside a class on this page, and then I call the include inside one of the functions in this class. For some reason when I include the header from within the function inside the class it doesn't seem to see the logged in variable and displays the login.

    Any ideas on why this is happening, or how I can get around this?

  2. #2
    SitePoint Wizard triexa's Avatar
    Join Date
    Dec 2002
    Location
    Canada
    Posts
    2,476
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    function variables are local?

    Outside stuff can't see variables used in the function, and anything inside the function can't see variables outside of it.

    you could either "global $var" or $GLOBALS['var'], etc..
    AskItOnline.com - Need answers? Ask it online.
    Create powerful online surveys with ease in minutes!
    Sign up for your FREE account today!
    Follow us on Twitter


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
  •