Originally posted by Rohan Hill
Yes, that's exactly what it means 🙂 Just put include('page.php'); in all your scripts where you want the contents of page.php to be processed.
Hello Rohan,
After I saw your comments about using the include() statement (see below), as well as your status as a "Senior Member," I decided to write to you to see if you could help me with a problem I'm having.
I followed all of the messages in this thread, but my experiments seem to indicate a particular limitation with the include() function that wasn't mentioned here. I too have created header and footer files that I would like to "wrap" around most but not all pages on my website. My original plan was to create these header & footer files, place them in one directory, and then call them on each page using include(). The problem I'm encountering is that the include() function only works when the file it is calling is located in the same directory as the script that is making that call. In other words, the only way to include the header and footer on all the pages that I want to have them is to place all the pages (header, footer, and content pages) in a single folder.
Have you found this to be the case as well? Some of our site's functionality depends upon having the files separated into different directories, so I can't really drop all the files into the same folder.
I've come across notes in the manual that talk about the include path and after checking our PHP configuration using phpinfo(), I see that it is configured to look in only two places. One is the directory of the calling script, which changes dynamically depending on where the calling script is located, and the other is a directory that I don't have access to - /usr/local/lib/php (we're on a shared server at Earthlink.net).
Well, my hands are tied. Any ideas on what I might be able to do to make this work? Here are a couple other limitations that bear in on this:
I don't want to include the header & footer on all pages (just most of them).
The header and footer files have PHP code in them, so readfile() wouldn't be a good choice for this either.
I'm beginning to think that the only option is to break the PHP code out of the header and footer files and create static html includes that can be brought in via readfile(). But this would still be a major bummer because I have 7 or 8 functions that would have to be embedded on each PHP page (by PHP page I'm referring to the script that reads in the static html files and builds the final page) which means there would no longer be a convenient way to update the entire site if those functions need to be changed.
Please accept my apologies for the length of this message (I'm an engineer by profession and tend to give every last detail when it comes to trouble-shooting!!).
Well, this is quite a pickle I'm in, and I'd definitely be grateful for any help you could offer.
Kind regards,
Tim