SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2005
    Posts
    45
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Cool Including PHP Variables on All Pages?

    I've been working on tweaking the layout of my wrestling site, so I set up a sub-folder at http://www.purelywrestling.com/layout and just worked with one index.php file for all of my coding, which included phpBB forum coding that was being grabbed at the top of the page.

    When I finished the layout how I wanted, I set up my index page to have PHP includes like I always do. I have one include for the stuff above the head, one for the top of my layout, one for the middle, one for the right, and one for my footer.

    So after I did all this, the phpBB coding was not being recognized. I eventually figured out that it was probably because the phpBB coding at the top was only being recognized on phpBB and not my middle php included page, which is where I want to display the actual forum thingys.

    So, how would I go about including the php thing in all of my pages, so that I can still use includes? It's kinda annoying just having one index.php file, since I prefer editing my coding in small sections.

    Any help is appreciated...if I wasn't clear enough in my explanation, tell me and I'll try to furthur elaborate.

    P.S...I tried a Google search, but I either didn't understand what they said, or just didn't really know "what" to search for.
    Pro Football Critics - The Latest News in Pro Football
    Purely Wrestling - The Latest News in Wrestling

  2. #2
    SitePoint Zealot Coastal Web's Avatar
    Join Date
    Jan 2006
    Location
    Oregon, U.S.
    Posts
    131
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello Chris...

    If l understand your inquiry correctly this should solve the problem.
    After the page has been included ie:

    //page where variables are declaired....
    include('some_variables.php');

    //snag them like so:
    $some_variable = $GLOBALS['some_variable'];

    For testing purposes.. create two documents.
    1 called: some_variables.php

    in it put:
    <?php
    $some_variable = "this is a global variable";
    ?>

    Create a 2nd page and place this code in it:
    <?php
    include('some_variables.php');
    $some_variable = $GLOBALS['$some_variable'];

    echo $some_variable;
    ?>

    this should do the trick!


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
  •