January 31st, 2000, 11:18 AM
I'm pretty new at php3 (and coding in general) and would appreciate any help. I would like to create a common header file, and my php pages would include this header file to be displayed at the top of the page. The thing is some php pages will need to have a few differences in the header. Instead of making a bunch of different header files, I'd like to make one, and a php script would display a different header depending on which page called the header. How would I do this? (Thanks!)
January 31st, 2000, 01:54 PM
Various ways this could be done. I'm assuming there are not major differences and still only be just a couple different options? Try this:
inside header.php3 you can display different options based on the setting of $option (or even if it isn't set. One way could be:
$file = "option".$option.".php3";
That way your different options have their own include for ease of editing (which is why you're doing it this way anyway
Plus you can add more options to the header very easily.
January 31st, 2000, 03:10 PM
Thanks for the reply! But I think this isn't quite what I was thinking (if I'm reading your example right, which I may very well not be). What I'd like is all the different header options in one file(header.php3)
So my header.php3 would look something like:
<html>My calendar page header
<html>My Discussion forum header
<html>My links page header
So say on my discussion page, I'd include the header.php3, and the correct header (option 2) would be displayed.
January 31st, 2000, 03:28 PM
In that instance you could use a switch..case construct, see the manual.