Quick PHP Tip

Quick PHP Tip

Did you remember to manually update your copyright statement to 2010? With one line of PHP all your problems can be solved!

By Jacob Haug on January 26th, 2010 in Tips & Tricks | Print This Article

Recently, I was reading an article on Smashing Magazine called…”Don’t Forget The Small Stuff This Year“, and within that article it reminded users to update their copyright statement each new year!

Have you ever forgotten to update your copyright statement to 2010? I know I have, however; let’s make sure that doesn’t happen again. With this short PHP code snippet, your statement will automatically update! How cool is that?

<p><strong>&copy; Copyright 2010 <a href="/">The Web Squeeze, LLC.</a> All Rights Reserved.</strong></p>

We’re going to change the above to…

<p><strong>&copy; Copyright <?php echo date('Y'); ?> <a href="/">The Web Squeeze, LLC.</a> All Rights Reserved.</strong></p>

The key in the above code is this line…

<?php echo date('Y'); ?>

The above line of code is using PHP’s built in date function. We’re saying echo out the current year (Y) in a 4 digit format. (e.g. 2010) If you’ve never used the date function, or want to customize the above a bit further, check out the date function.

http://us2.php.net/manual/en/function.date.php

I hope this helps make your life just a tad easier!

Did you like it?

Help us spread the word!

About The Author

Jacob Haug
Jacob Haug
My name is Jacob Haug, and I spend the majority of my time in website development. I donate many hours each day helping the web community with technical aspects of website design and development. My current project is The Web Squeeze. A “NEW”, “FRESH”, Web Design and Development community dedicated to helping make the internet a better place! @JacobHaug

Comments

  1. Gravatar Icon
    Jeevan M Paran said :

    I bet you are Jacob!
    You have just reminded me to change them. I did read the same article in Smashing Magazine but somehow I did not think about it, silly me ^_^

  2. Gravatar Icon
    Stuart Wagner said :

    Great tip! I always do this for designs since it would be a hassle to have to find each site I ever built each year, just to update that little number.

    PHP saves the day, once again! :D

  3. Gravatar Icon
    Japh said :

    Nice little tip, Jacob :)

    I believe technically copyright dates should be a range if they span more than one year (which they will if you’re changing the date).

    So really, your code should be more like:
    <p><strong>© Copyright 2008 – <?php echo date(‘Y’); ?> <a href=”/”>The Web Squeeze, LLC.</a> All Rights Reserved.</strong></p>

    Or something similar :)

  4. Gravatar Icon
    Jeevan M Paran said :

    I saw people do like that. What is the different between that two?
    Which is the best or should I say, which one should we use?

  5. Gravatar Icon
    Linda Chadbourne said :

    I wasn’t aware of this tip but this would certainly come in handy. I’m going to implement this on my client sites. I use a span of years in copyrights so Japh’s code will work well for the majority. However when I develop a brand new site for a new business, Jacob’s will work for the first year!
    Thanks!

  6. Gravatar Icon
    Linda Chadbourne said :

    I wasn’t aware of this tip but this would certainly come in handy. I’m going to implement this on my client sites. I use a span of years in copyrights so Japh’s code will work well for the majority. However when I develop a brand new site for a new business, Jacob’s will work for the first year!
    Thanks!

  7. Gravatar Icon
    Japh said :

    Hmm… so longer-lasting code then, so you can use it on new projects too! ;)

    <p><strong>© Copyright <?php $year=’2008′; echo (date(‘Y’) == $year ? $year : $year.’ – ‘.date(‘Y’)); ?> <a href=”/”>The Web Squeeze, LLC.</a> All Rights Reserved.</strong></p>

  8. Gravatar Icon
    Marc Fraser said :

    I believe, from what I’ve read, that using a Copyright deceleration at the bottom of your website doesn’t matter. Anything you publish to the internet is copyright of the website, regardless of whether you have this deceleration or not. A Copyright deceleration, however, is useful if you are displaying another person’s work on your website.

    Disclaimer:
    Please remember, that in no way am I an IP (Intellectual Property) lawyer. Thus, accept no liability for the above statement.

  9. Gravatar Icon
    Jacob Haug said :

    @Japh @Linda

    It’s all a matter of personal preference which you use. It’s not required to use a range, however, some prefer that.

    @Marc

    That’s a good point Marc!

    The humble copyright notice is always useful to show in the footer, as a way of stating your claim over a site. Interestingly, however, it is not required for you to have copyright over the graphics, content and artwork of your site. This comes into place as soon as you’ve created the content and placed it in the public domain. Placing a copyright notice is still advisable to deter potential plagiarists and stake your claim.

Do you have something to say?

Live Comment Preview