r/PHPhelp • • Oct 23 '26

one single page of php code (v5.6) upgrade to 7.4: help request

I have one single page of code (functions.php), no mysql, that was written with php 5.6 and now needs an upgrade to 7.4.

I downloaded rector but I have no clue how to use that.

Can anyone help me to upgrade this page please? I have no php experience.

4 Upvotes

24 comments sorted by

23

u/vincent_sch Oct 23 '26

If your host offers PHP 8.2 or newer, you should target that instead. 7.4 got its last security fix in November 2022, so otherwise you do this upgrade twice.

10

u/colshrapnel Oct 23 '26

Yes, anyone can. You could have gotten it fixed already if just posted it here.

6

u/No_Astronomer9508 Oct 23 '26

Setting up Rector for a single functions.php file is completely unnecessary and way too complicated if you don't have PHP/CLI experience. Since it's just one file without MySQL, upgrading it from PHP 5.6 to 7.4 is usually straightforward (mostly fixing deprecated functions, count() checks, or legacy constructor syntax).

If you'd like, you can post the code of functions.php here (or link a Pastebin / Gist), and I can take a look at it and maybe help to convert.

1

u/Erik84750 Oct 23 '26

Hi, many thanks for your fast replies.

I made the file available in Google Drive and in Github:

https://drive.google.com/drive/folders/1-tltwn4mHsXHv_xyB9mncs3m7y6A1uvW?hl=nl

https://github.com/Erik84750/PHP-upgrade

This file is also linked to a config.php fle and a form.php file. I am not sure if these require an upgrade to, so I posted them too.

The form.php file is the one visible here: https://studio61.be/website/en/formulier-en.html

It basically is a simple form-to-send-by-email.

1

u/mic_decod Oct 25 '26

Since you are already on github, open a codespace and let copilot do the migration. It can also make the layout more mobile friendly.

1

u/Takeoded Oct 26 '26

PHP-upgrade is either private, or deleted. I can't access it.

4

u/BokuNoMaxi Oct 23 '26

Brother, just let AI handle this if you don't know how to code.. task is done in 10 minutes and it gets updated to PHP 8.5 ...

1

u/MateusAzevedo Oct 23 '26

Just update the PHP version, the latest one you can. If you have access to edit php.ini, set error_reporting = E_ALL and display_errors = 1. If not, add error_reporting(E_ALL); and ini_set('display_errors', 1); as the first lines of code in functions.php.

Go to the page(s) that use those functions, see if any error pop up and fix them. If you don't know how to do it, post the code here with the error messages you got and we can take a look.

Remember to turn display_errors off afterward.

But for such amount of code, and if it doesn't do anything fancy, there's a high chance it is already compatible without any changes.

1

u/Erik84750 Oct 23 '26

I have access to the webserver of the webhost, there I can set the php version to 5.6, 5.5, 7.0, 7.1, 7.2, 7.3, 7.4, 8.0, 8.1, 8.2, 8.3.

But anything higher than 5.6 breaks the 'send email' function. Currentlmy the webhost has mandatory set the minimum php version to 7.4.

My form-to-send page is visible, intact, but emails cannot be sent.

This is an example of the current send-to-email form page: https://studio61.be/website/en/formulier-en.html

Where do I find php.ini? I cannot see any such file in my server directories?

The error-log.txt is set at 666, so read and write allowed, but is empty for now.

3

u/Calman00 Oct 23 '26

Claude code or codex

1

u/vasilegoian Oct 23 '26

Hi. I've sent you a PM. Since it's just a file I'll help you for free. Hit me up.

1

u/vasilegoian Oct 23 '26

Wow. Nice. I offered help on r/PHPhelp and I got downvoted. Faith in humanity unchanged.

2

u/Erik84750 Oct 23 '26

I do not understand either.. I gave you an upvote Vasili.

2

u/kanine69 Oct 24 '26

If there is nothing sensitive in it, you post to GitHub in a public repo and the whoever's interested can help you in a public way and get peer checked.

But honestly Claude Code would eat this in no time. I could run it though but as others say safer to make it public so it can get reviewed.

And just go for 8.5.12

5

u/MateusAzevedo Oct 23 '26

It isn't advised to offer private help.

When doing so, 2 issue can happen:

1- No one else could review and comment on what you provided, possibly spotting issues with your solution. But the most important, is to avoid bad developers recommending objectively bad code, like containing SQL injection.

2- None of the solution will be public and so, other people in the future will not benefit from this sub if they happen to have the same issue. This is why rules #5 and #9 exist.

The recommendation is to ask OP to provide their code for everyone to see, and the solution then will also be available for everyone.

2

u/equilni Oct 23 '26

How helpful is it if programming sub/forum turned into a for-sale forum. PM sent in every response. How helpful is that to anyone searching for a similar situation in the future.

1

u/Devnzian Oct 23 '26

Yes very much possible and it's better to conver 8.2 or later version not 7.4.

1

u/martinbean Oct 23 '26

You don’t need to upgrade to 7.4. You need to upgrade to PHP 8. PHP 7.4 is still massively outdated.

1

u/elevarq Oct 24 '26

Moving from one unsupported version to another unsupported version. What’s the point? Waste of time.

If you want to spend some time, and/or money, migrate to a supported version of your favorite software platform.

1

u/Opinion_Less Oct 24 '26

I would bet that you could point this at 8.2 and get the latest patch for rce vulnerabilities and not have to change anything that you'd changed to get to 7.4

1

u/miglisoft Oct 28 '26

Hi, I’ve just seen your post; rather than updating some rather outdated code, I can offer you a more suitable solution. If you’re interested, please feel free to contact me via private message. Just so you know, I’m French.

0

u/[deleted] Oct 23 '26

[deleted] — view deleted comment

1

u/Erik84750 Oct 23 '26

Hi psyon, I have no mysql in my code, no calls to magic quotes.

But changes to '_construct' I would not now how to do that. Basically, when moving the webhost server php version from 5.6 to 7.4 the actual page involved ( https://studio61.be/website/en/formulier-en.html ) still is intact, but the contact form does not transmit emails anymore.

0

u/[deleted] Oct 23 '26

[deleted] — view deleted comment

0

u/Erik84750 Oct 23 '26

I find this snippet of code in my functions.php:

[code]

### INTINTIAL VARS - Some null, some with stuff

$user_message = "";

$id_value = "";

$name_value = "";

[/code]