12-26-2006, 12:01 PM
· #1 NamePros Regular
Join Date: Mar 2006
Posts: 223
NP$: 163.00 (
Donate )
Auto Update Copyright [PHP]
Have you ever made a site and always had to change the copyright? Well you came to the right place!
Here is a PHP code which will automatically update to the current year
<?PHP $date = date('Y'); echo ("Copyrighted 1950 - $date"); ?>
What that script does it, it outputs the current date!
More tutorials coming soon at:
http://www.netsuhi.com
12-26-2006, 12:06 PM
· #2 NamePros Regular
Name: Ron
Location: Chicago Burbs
Join Date: Aug 2003
Very useful
thanks.
12-26-2006, 12:10 PM
· #3 NamePros Regular
Join Date: Mar 2006
Posts: 223
NP$: 163.00 (
Donate )
Glad I could help
12-26-2006, 01:10 PM
· #4 www.RickyMills.com
Name: Rick Mills
Location: Herts, UK
Join Date: Sep 2005
Posts: 3,529
NP$: 497.52 (
Donate )
Just a note, you don't need brackets round echo tags in php4+
e.g:
PHP Code:
<?php
$date = date ( 'Y' );
echo "Copyrighted 1950 - $date" ;
?>
12-26-2006, 01:40 PM
· #5 Buy my domains.
Name: Dan
Join Date: Feb 2006
Posts: 2,800
NP$: 54.00 (
Donate )
PHP Code:
<?php echo "Copyright © 1950 - " . date ( "Y" ); ?>
12-26-2006, 01:45 PM
· #6 NamePros Regular
Join Date: Mar 2006
Posts: 223
NP$: 163.00 (
Donate )
Thanks for the help guys!
12-26-2006, 02:06 PM
· #7 Stud Sausage
Location: England
Join Date: Dec 2006
Posts: 1,545
NP$: 32.41 (
Donate )
rmwebs, i don't think it is since php4. echo is and also has been a language construct which do not require parenthesis. To my knowledge is it not version dependent.
Dan, now you're just being picky lol!
technically....
PHP Code:
echo 'Copyright © 1950 - ' . date ( 'Y' );
...would be better as we do not variables names to be expanded. Now
that's being picky lol
12-26-2006, 02:53 PM
· #8 Buy my domains.
Name: Dan
Join Date: Feb 2006
Posts: 2,800
NP$: 54.00 (
Donate )
PHP Code:
echo 'Copyright © 1950 - ' . date ( 'Y' );
Those extra 3 bytes were killer.
12-26-2006, 03:04 PM
· #9 Stud Sausage
Location: England
Join Date: Dec 2006
Posts: 1,545
NP$: 32.41 (
Donate )
touché Dan.
12-26-2006, 10:31 PM
· #10 DNOA Member
Location: USA
Join Date: Jul 2004
Posts: 1,116
NP$: 176.10 (
Donate )
Why not just do?
PHP Code:
Copyright & copy ; 1995 - <? php echo date ( "Y" ); ?>
12-27-2006, 04:54 AM
· #11 Stud Sausage
Location: England
Join Date: Dec 2006
Posts: 1,545
NP$: 32.41 (
Donate )
Originally Posted by jdk Why not just do?
PHP Code:
Copyright & copy ; 1995 - <? php echo date ( "Y" ); ?>
I think it was assumed that the lines previous to this one would have been in php hence you would not bother with the advantages of breaking out of php to output and simply echo it as it is only 1 line.
12-28-2006, 09:58 AM
· #12 NamePros Regular
Join Date: Feb 2006
Posts: 588
NP$: 1540.95 (
Donate )
If those bytes really matter :P, this will work for PHP 5+ :
PHP Code:
Copyright & copy ; 1995 - <?= date ( "Y" ); ?>
12-28-2006, 11:32 AM
· #13 Stud Sausage
Location: England
Join Date: Dec 2006
Posts: 1,545
NP$: 32.41 (
Donate )
Let us think of compatibility jromentan! What if short_open_tag is disabled lol.
Anyway, that will work for all versions of php, not just php5+. Also it can be beaten lol! Remember just how important those bytes ares
PHP Code:
Copyright & copy ; 1995 - <?= date ( "Y" ) ?>
The closing tag (?>) also adds a semi colon, so you don't have to
01-20-2007, 03:22 PM
· #14 NamePros Member
wow LOL this site has some picky people
lol
01-20-2007, 03:57 PM
· #15 Senior Member
Join Date: Dec 2006
Posts: 2,851
NP$: 1127.20 (
Donate )
Originally Posted by . Adam . wow LOL this site has some picky people
lol
i know eh?... and i thought the cost of bandwidth was going down!! good job though guys; striving for excellence is enviable.
__________________
- shockie
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off