02-26-2007, 05:26 PM
At the footer of each page, I have the copyright year and the version number of the code.
Normally, I would have to go back to each page I have created and update the copyright year and the version number, as time goes on.
Instead, I am interested in a simple PHP script, that will print the copyright year from one text file and the version number from another. (or one text file to do both, whichever is simplier in PHP)
I tried Googling this, but I wasn't sure how to explain it in a set of keywords, so I couldn't find anything relevant.
Thanks a lot in advance.
EDIT: If you'd like to see the way the copyright year and version number look, here's the page in question (http://www.blkflm.com/TESTING6).
02-26-2007, 05:41 PM
Create a file called copyright.php and have that file read the information from the file. Then use include('copyright.php') in all of your pages.
02-26-2007, 05:47 PM
Hmm, well thank you for the quick reply.
However, being a beginner to PHP I don't know how to "have...[copyright.php]..read the information from the file" I wouldn't even know where to start.
I'm not asking the experts here to do the work for me, but if they know what the PHP technique I want to use is called and can give me a good set of keywords, I'd be willing to track down a tutorial myself.
Or someone can just type out what the script should look like, if they're in the mood to do so. :thumbsup:
02-26-2007, 05:58 PM
02-26-2007, 05:59 PM
My apologies... I usually go with a high level answer and then narrow down with details if needed.
The easiest way to bring in the contents of a file is with the function file() (http://us2.php.net/manual/en/function.file.php).
This puts each line of the file into an array.
Let's make this as easy as possible, and assume your file has two lines, the first line containing the copyright year, and the second line containing the version number.
The copyright.php would look something like this:
$footerInfo = file('footerinfo.txt');
print "Copyright ".trim($footerInfo).", version ".trim($footerInfo)\n";
Then just include copyright.php in your pages:
02-26-2007, 09:14 PM
Aha! Thanks so much Fumigator, that's perfectly what I needed!
aedrin: Thanks also, I'll have to look through that if I ever need the function for other uses in the future.
EDIT: Fumigator : / I tried to give you rep but got this message:
You must spread some Reputation around before giving it to Fumigator again. I'll be sure to give you some next time I'm allowed to.
02-26-2007, 11:03 PM
if I ever need the function for other uses in the future.
It's a very useful feature of PHP, so I'm sure you will.