PHP Date Exercises : Display the copyright information in the specified format
1. Copyright Info Display
Write a PHP script which will display the copyright information in the following format. To get current year you can use the date() function.
Expected Format : © 2013 PHP Exercises - w3resource
Sample Solution:
PHP Code:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Copyright Information</title>
</head>
<body>
<!-- Output the copyright symbol followed by the current year -->
<p>© <?php echo date('Y'); ?> PHP Exercises - w3resource</p>
</body>
</html>
Output:
View the output in the browser
Explanation:
In the exercise above,
- <!DOCTYPE HTML>: Specifies the document type and version of HTML being used.
- <html>, <head>, <meta>, <title>: These tags define the structure and metadata of the HTML document.
- <body>: Begins the body of the HTML document.
- <?php echo date('Y'); ?>: This PHP snippet dynamically generates the current year using the date() function with the format specifier 'Y'.
- <p>© <?php echo date('Y'); ?> PHP Exercises - w3resource</p>: This paragraph element contains the copyright symbol, the current year generated by PHP, and additional text.
- </body>, </html>: Closes the body and HTML tags, respectively.
Flowchart :

For more Practice: Solve these Related Problems:
- Write a PHP script to display the copyright notice for a website, dynamically calculating the current year and allowing the site name to be passed as a parameter.
- Write a PHP function that generates a formatted copyright line with a custom message and year based on user input.
- Write a PHP program that reads the site name from a configuration file and outputs the full copyright notice with the current year.
- Write a PHP script to build a copyright string that includes multiple dynamic parts (year, website name, rights reserved) and prints it in a styled HTML element.
Go to:
PREV : PHP Date Exercises Home.
NEXT : Birthday Countdown.
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.