Forum Moderators: coopster

Message Too Old, No Replies

Any software to help change PHP5.6 scripts to PHP7.4 compatible?

scripts run fine for years under php5.6 but need to update

         

internetheaven

7:09 pm on Oct 19, 2022 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have a few dozen PHP files that are running fine under PHP5.6 on the server. As soon as I change to PHP7 (any variant) all the website pages crash. So I'm guessing there are some incompatible bits. How do I find them? I've just been reading through:

[php.net...]

and the 'deprecated' section but most of that doesn't appear in any of my scripts. Is there a good program, online tool, or list to help me find the sections that need to be changed in each script?

Any help appreciated.

londrum

7:25 pm on Oct 19, 2022 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



…just a note to say that if you're going through all these changes then you might want to go straight to PHP8 instead. i was on PHP7.4 until my host let me know that support for it is ending in november

from memory, the big thing i had to change moving to 7.4 was changing all the mysql calls to mysqli - [stackoverflow.com...]

Dimitri

7:52 pm on Oct 19, 2022 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member Top Contributors Of The Month



This might exist, but I would not recommend using such tool. When a function has been depreciated, then removed, I doubt a software can generate an alternative code.

So I'm guessing

You don't need to guess. Read the log files, where error messages are ... logged.

On your dev machine, just enable "display_errors" and the error message will show directly on the page.

No to discourage you, but then, you'll have to migrate your code from PHP 7 to 8 ...

robzilla

10:56 pm on Oct 19, 2022 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



It's not so much the deprecated features but the list of backward incompatible changes you need to look at: [php.net...]

One of the most impactful changes was the removal of the MySQL functions like mysql_connect(), in favor of MySQLi or PDO.

However, as noted you should just check your error logs to see which bits of code can no longer run on PHP 7/8.

lucy24

12:12 am on Oct 20, 2022 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



check your error logs
Assuming for the sake of discussion that it’s your own server. I don't think OP said. If you're on shared hosting you may not have access to php logs, though you should still be able to specify which php version, within reason. (Quick look at my own sites reveals a range from 5.6 to 8.1, plus a couple of older 5.x versions that, based on datestamp, haven't been supported since 2019.)

robzilla

8:21 am on Oct 20, 2022 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I've never seen a shared hosting space where you don't have access to your access and error logs somehow, whether from a control panel (Plesk/cPanel/DirectAdmin) or through FTP.

If for some reason you don't, then as Dimitri noted you may be able to set display_errors so that errors are shown in the output in the browser.

lucy24

4:35 pm on Oct 20, 2022 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Access and error logs, yes, of course. But php logs are a separate thing.

robzilla

4:57 pm on Oct 20, 2022 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



PHP errors are generally reported back to the web server, which takes care of logging; in most cases in the error log file of the "virtual host".

I believe that's the default setting for both mod_php in Apache and PHP-FPM.