- This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
Viewing 4 posts - 1 through 4 (of 4 total)
- The forum ‘CSS’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
I have about 10 different pages that I want to all display the same string of text, which changes often. Without using an iFrame, how can I embed this string of text onto each of the ten pages? My goal is to only have to change the text in one file rather than all ten.
Thanks in advance!
Server side languages would be the best way of choice. Using a ‘php’ include() to bring the text in. There are plenty of tutorials out there for this sort of thing – Google is your friend.
If your hosting doesn’t allow server side languages like ‘php’ then it better be free! Last ditch effort would be to load it into the page with JavaScript but that is not it’s purpose!
Yes! That did it, thank you!!
BTW, it too me a while to figure out that my main page had to be a PHP file to use a PHP Include. However, the file that I am pulling the embedded text from seems to be able to be any extension; .HTM, .PHP, .TXT, etc.
if you use a ‘.htm’ file then you could access it’s contents from the URL, not always desired.
The best use for a basic php include would be declaring some global variables. If you were to create and include a file at the top of your document that contained php like this:
global $sitetitle = "My Site";
global $funnymsg = "Theory and practice are the same, in theory. But different in practice";
?>
You could then use the variable whenever you liked:
Welcome to !
Here at we want you to know that
If someone was to load just the include into their browser they would see nothing, as no HTML is generated. That’s why dynamic pages rock!
(The code above has not been checked for errors!)