Keep Your Website’s Copyright Notice Up-to-Date with PHP

Last Updated on: January 17, 2023

The footer area of your website is underrated – you can use it for important links and to show your visitors that your website is regularly updated.

This code snippet uses the date() function in PHP to output the current year. By including it in your copyright notice, the year will automatically update each year, ensuring that your site always appears up-to-date.

Here’s an example of how you can use this code in the context of a website’s footer:

<footer>
    <p>Dev Chunks is copyright <?= date("Y") ?></p>
</footer>

In this example, the PHP code is included within an HTML footer element, and the output will be the current year. This will be displayed on the website’s footer with the text “Dev Chunks is copyright – 2023”.

You can also add the date of the update or the last modification of the page at the end of the footer.

<footer>
    <p>DevChunks is Copyright 2023 (Last Updated: <?= date("F d, Y", filemtime($_SERVER['SCRIPT_FILENAME'])) ?>)</p>
</footer>

This will show the last updated date of the page in the format “month day, year” .

In addition to this, you can also include other dynamic information in your footer such as the number of users currently online, a list of recent blog posts, or links to your social media profiles.

<footer>
    <p>DevChunks is Copyright <?= date("Y") ?> (Last Updated: <?= date("F d, Y", filemtime($_SERVER['SCRIPT_FILENAME'])) ?>)</p>

    <p>Users Online: <?= $users_online ?></p>

    <ul>
    <?php
        $recent_posts = getRecentPosts(); //retrieve recent posts from a database or API
        foreach($recent_posts as $post){
            echo '<li><a href="'.$post['link'].'">'.$post['title'].'</a></li>';
        }
    ?>
    </ul>

    <p>Follow us on: 
        <?php
        $social_links = getSocialLinks(); //retrieve social links from a database or API
        foreach($social_links as $social){
            echo '<a href="'.$social['link'].'">'.$social['name'].'</a> | ';
        }
        ?>
    </p>

</footer>


Get notified of new posts:


Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *