NameSilo

Auto Update Copyright [PHP]

Namecheap AuctionsNamecheap Auctions
Namecheap AuctionsNamecheap Auctions
SpaceshipSpaceship
Watch

Ryder

Established Member
Impact
5
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 :D

<?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
 
1
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
Very useful :) thanks.
 
0
Close
Glad I could help :D
 
0
Close
Just a note, you don't need brackets round echo tags in php4+

e.g:

PHP:
<?php 
$date=date('Y');
echo"Copyrighted 1950 - $date";
?>
 
0
Close
PHP:
<?php echo "Copyright © 1950 - " . date("Y"); ?>
 
0
Close
Thanks for the help guys!
 
0
Close
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:
echo 'Copyright © 1950 - ' . date('Y');
...would be better as we do not variables names to be expanded. Now that's being picky lol
 
0
Close
PHP:
echo'Copyright © 1950 - '.date('Y');
Those extra 3 bytes were killer.
 
0
Close
touché Dan. :hehe:
 
0
Close
Why not just do?

PHP:
Copyright © 1995 - <?php echo date("Y");?>
 
0
Close
jdk said:
Why not just do?

PHP:
Copyright © 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.
 
0
Close
If those bytes really matter :P, this will work for PHP 5+ :

PHP:
Copyright © 1995 - <?=date("Y");?>
 
0
Close
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:
 Copyright © 1995 - <?=date("Y")?>

The closing tag (?>) also adds a semi colon, so you don't have to :D
 
0
Close
wow LOL this site has some picky people ;) lol
 
0
Close
. Adam . said:
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.
 
0
Close
DomainEasy: white label portfolios are live. Enable yours.

We're social

Escrow.com
Spaceship
CryptoExchange.com
Domain Recover

NamePros updates

Quick replies: search, your most used replies, and more on every post
Quick replies are easier to find and use now. The quick reply menu has a search box. Type a few letters to find the reply you want. A...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back