Skip to Content
It is currently July 5th, 2022, 7:58 am

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: October 31st, 2021, 9:03 am 
Offline
Senior User
Senior User

Joined: January 1st, 2009, 8:50 pm
Posts: 147
Hello,

I have FINALLY gotten most of the code in my stations rewritten so that I can move up to PHP 7x, but when I activated the new version a message appears above my content saying that the each() function has been depricated. Luckily they point to where it is used: Library/Common/xml.php , line 78. It's actually in there 6 times (functions CompakTree, ChildKeyIsNum, MakeAttr, ArrayToXML, Keys2Lower, and XMLheader).

Can I get rid of these functions, or is there a replacement for the "each()" function?

Thank you,
Terry


Top
 Profile  
Reply with quote  
PostPosted: November 3rd, 2021, 9:29 am 
Offline
SVS Member
SVS Member

Joined: December 6th, 2004, 9:00 am
Posts: 8306
Location: Cologne (Germany)
Code:
while (list($a,$b) = each($c))

becomes:
Code:
foreach ($c as $a => $b)


For more info on all the steps necessary to get your code up to PHP8 standards, please have a look at this pinned thread in the Web Features forum:
viewtopic.php?f=22&t=72729

And this one for the detailed instructions on how to get it PHP7-ready:
viewtopic.php?f=22&t=53771

Last but not least: If this is a "production environment" you should turn off display_errors and instead log your errors to a logfile. Also turning off error_reporting for deprecations, warnings and notices might be a good idea in general depending on your use case. (At work, we usually set error_reporting to the maximum possible, but don't display any errors to the user at all)

_________________
Benedikt Bauer - SVS (Spacial Volunteer Support)

Shop for readymade PAL scripts by countrywesterndj - Or get a custom script made by me (or others)

My Project:
Send "Now Playing" from SAM to Twitter and/or Facebook | Sourcecode


Top
 Profile  
Reply with quote  
PostPosted: November 4th, 2021, 10:31 am 
Offline
Senior User
Senior User

Joined: January 1st, 2009, 8:50 pm
Posts: 147
Mastacheata wrote:
Code:
while (list($a,$b) = each($c))

becomes:
Code:
foreach ($c as $a => $b)


For more info on all the steps necessary to get your code up to PHP8 standards, please have a look at this pinned thread in the Web Features forum:
https://support.spacialaudio.com/forums ... 22&t=72729

And this one for the detailed instructions on how to get it PHP7-ready:
https://support.spacialaudio.com/forums ... 22&t=53771

Last but not least: If this is a "production environment" you should turn off display_errors and instead log your errors to a logfile. Also turning off error_reporting for deprecations, warnings and notices might be a good idea in general depending on your use case. (At work, we usually set error_reporting to the maximum possible, but don't display any errors to the user at all)


Thanks!
I made the 6 changes and no more errors.
Where can I find the setting to turn off the errors?


Top
 Profile  
Reply with quote  
PostPosted: November 8th, 2021, 5:58 am 
Offline
SVS Member
SVS Member

Joined: December 6th, 2004, 9:00 am
Posts: 8306
Location: Cologne (Germany)
I think there's more than 6 occurences of while - each as detailed over here in the PHP7 thread as optional change.
viewtopic.php?p=219049#p219049

display_errors should be set in your php.ini, same for the error_level:
https://www.php.net/manual/de/errorfunc ... lay-errors
https://www.php.net/manual/de/errorfunc ... -reporting

If you're running Apache, you can probably also set these values in a .htaccess file on the webroot or at least at the topmost folder of your SAM templates on your server by adding these lines:
Code:
php_value display_errors 0
php_value error_reporting 2147483647

_________________
Benedikt Bauer - SVS (Spacial Volunteer Support)

Shop for readymade PAL scripts by countrywesterndj - Or get a custom script made by me (or others)

My Project:
Send "Now Playing" from SAM to Twitter and/or Facebook | Sourcecode


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 19 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group