The Big Spring Sale! Up to 50% off!

Copyright script problem

Romuba
56 Posts
Romuba posted this 29 August 2023
Ask a Question

On a new site when I try to add a copyright script:

<p>© {source}&lt;?php<br /> ini_set('date.timezone', 'Africa/Johannesburg');<br />$startYear = 2007;<br /> $thisYear = date('Y');<br /> if ($startYear == $thisYear) {<br /> echo $startYear;<br /> }<br /> else {<br /> echo "{$startYear}-{$thisYear}";<br /> }<br /> ?&gt;{/source} <em>Bartwebsites</em> | All Rights Reserved.<br />{source}&lt;?php echo strftime('%A, %d %B %Y'); ?&gt;&nbsp;{/source}</p>
<p>Website &amp; Hosting by <a href="http://www.bartwebsites.com" target="_blank">Bartwebsites</a></p>

I get the following message:

Deprecated: Use of "self" in callables is deprecated in /home/siphoimx/public_html/administrator/components/com_nicepage/library/src/Processor/PositionsProcessor.php on line 33

On a new site when I try to add a copyright script: <p>© {source}&lt;?php<br /> ini_set('date.timezone', 'Africa/Johannesburg');<br />$startYear = 2007;<br /> $thisYear = date('Y');<br /> if ($startYear == $thisYear) {<br /> echo $startYear;<br /> }<br /> else {<br /> echo "{$startYear}-{$thisYear}";<br /> }<br /> ?&gt;{/source} <em>Bartwebsites</em> | All Rights Reserved.<br />{source}&lt;?php echo strftime('%A, %d %B %Y'); ?&gt;&nbsp;{/source}</p> <p>Website &amp; Hosting by <a href="http://www.bartwebsites.com" target="_blank">Bartwebsites</a></p> I get the following message: Deprecated: Use of "self" in callables is deprecated in /home/siphoimx/public_html/administrator/components/com_nicepage/library/src/Processor/PositionsProcessor.php on line 33

Last edited 29 August 2023 by Romuba

Vote to pay developers attention to this features or issue.
5 Replies
Order By: Standard | Newest
Support Team
Support Team posted this 29 August 2023

Hello Ross,

The error message you are getting is a deprecation warning. This means that the use of the self keyword in callables is deprecated in PHP 8.2, and will eventually become an error in PHP 9.0

The self keyword is not used in the code you provided. The problem is that the ini_set() function is deprecated in PHP 8.2. This means that it will eventually become an error to use this function in PHP 9.0.

To fix the error, you can use the date_default_timezone_set() function instead of the ini_set() function. The date_default_timezone_set() function is the preferred way to set the default timezone in PHP.

The following code will not generate an error:

<.?php
date_default_timezone_set('Africa/Johannesburg');
$startYear = 2007;
$thisYear = date('Y');
$copyrightYear = $startYear;
if ($startYear != $thisYear) {
$copyrightYear = $startYear . '-' . $thisYear;
}
echo '© ' . $copyrightYear . ' Bartwebsites | All Rights Reserved.';
?>

It may help you. Change only this part, the other part does not change.
<.?PHP deleted in here the ".", we added "." for the shown code for you. delete only this "." and copy all and replace it in your code.
...................................................
Sincerely,
George.
Nicepage Support Team

Please subscribe to our YouTube channel: http://youtube.com/nicepage?sub_confirmation=1
Follow us on Facebook: http://facebook.com/nicepageapp

Hello Ross, The error message you are getting is a deprecation warning. This means that the use of the self keyword in callables is deprecated in PHP 8.2, and will eventually become an error in PHP 9.0 The self keyword is not used in the code you provided. The problem is that the ini_set() function is deprecated in PHP 8.2. This means that it will eventually become an error to use this function in PHP 9.0. To fix the error, you can use the date_default_timezone_set() function instead of the ini_set() function. The date_default_timezone_set() function is the preferred way to set the default timezone in PHP. The following code will not generate an error: **<.?php date_default_timezone_set('Africa/Johannesburg'); $startYear = 2007; $thisYear = date('Y'); $copyrightYear = $startYear; if ($startYear != $thisYear) { $copyrightYear = $startYear . '-' . $thisYear; } echo '© ' . $copyrightYear . ' Bartwebsites | All Rights Reserved.'; ?>** It may help you. Change only this part, the other part does not change. <**.**?PHP deleted in here the ".", we added "." for the shown code for you. delete only this "." and copy all and replace it in your code. ................................................... Sincerely, George. Nicepage Support Team Please subscribe to our YouTube channel: http://youtube.com/nicepage?sub_confirmation=1 Follow us on Facebook: http://facebook.com/nicepageapp
Romuba
56 Posts
Romuba posted this 29 August 2023

Thank you, but the error is still there. The php displays as code instead of being parsed.

Thank you, but the error is still there. The php displays as code instead of being parsed.
Support Team
Support Team posted this 29 August 2023

Hi,

Please make sure that you added PHP code into the PHP element.

<?php
date_default_timezone_set('Africa/Johannesburg');
$startYear = 2007;
$thisYear = date('Y');
$copyrightYear = $startYear;
if ($startYear != $thisYear) {
$copyrightYear = $startYear . '-' . $thisYear;
}
echo '© ' . $copyrightYear . ' Bartwebsites | All Rights Reserved.';
?>

...................................................
Sincerely,
Olivia
Nicepage Support Team

Please subscribe to our YouTube channel: http://youtube.com/nicepage?sub_confirmation=1
Follow us on Facebook: http://facebook.com/nicepageapp

Hi, Please make sure that you added PHP code into the PHP element. <?php date_default_timezone_set('Africa/Johannesburg'); $startYear = 2007; $thisYear = date('Y'); $copyrightYear = $startYear; if ($startYear != $thisYear) { $copyrightYear = $startYear . '-' . $thisYear; } echo '© ' . $copyrightYear . ' Bartwebsites | All Rights Reserved.'; ?> ................................................... Sincerely, Olivia Nicepage Support Team Please subscribe to our YouTube channel: http://youtube.com/nicepage?sub_confirmation=1 Follow us on Facebook: http://facebook.com/nicepageapp
Romuba
56 Posts
Romuba posted this 29 August 2023

Thanks. I have had to fiddle but have eventually managed to get it working. I was using a custom module initially.

Thanks. I have had to fiddle but have eventually managed to get it working. I was using a custom module initially.
Support Team
Support Team posted this 30 August 2023

Hello Ross,

Our team works for you, and we will be happy to hear if you like our product. We get thousands of thanks and no reviews from our satisfied customers. However, one unhappy customer leaves many bad reviews on various resources and social media.

You can leave your 5-star review, if applicable, at https://www.trustpilot.com/review/nicepage.com.

Please help us to develop Nicepage, and tell the world what you think about Nicepage.
...................................................
Sincerely,
George.
Nicepage Support Team

Please subscribe to our YouTube channel: http://youtube.com/nicepage?sub_confirmation=1
Follow us on Facebook: http://facebook.com/nicepageapp

Hello Ross, Our team works for you, and we will be happy to hear if you like our product. We get thousands of thanks and no reviews from our satisfied customers. However, one unhappy customer leaves many bad reviews on various resources and social media. You can leave your 5-star review, if applicable, at https://www.trustpilot.com/review/nicepage.com. Please help us to develop Nicepage, and tell the world what you think about Nicepage. ................................................... Sincerely, George. Nicepage Support Team Please subscribe to our YouTube channel: http://youtube.com/nicepage?sub_confirmation=1 Follow us on Facebook: http://facebook.com/nicepageapp
You must log in or register to leave comments