Should my web app still work fine?

first of all i love your service a lot …

just want to make sure

my web app is php 7.4 and the upgrades to your hosting service is 8.2 , should my web app still work fine?

another little question , suddenly some of my web apps not working even i create another account with another subdomain , is because the updates ?

thanks in advance

Whether or not it works depends entirely on the code you are using.

What is happening instead? Just saying “it does not work” is not helpful at all.

5 Likes

thanks a lot @Greenreader9 for your reply
i wont bother anyone about the error itself because it should be clear that its because the version of code i use
but the question now , can i choose to use version 7.4 instead of 8.2 ?
many people wont update there codes

Unfortunately, switching your PHP version is only supported in premium hosting.

Well, they should. PHP 7.4 has reached its end of life quite some time ago:
https://www.php.net/supported-versions.php

6 Likes

Hi aqsaprograms,

You should definitely consider updating to PHP 8, not just because of the security but also performance, PHP 8 is way faster than PHP 7.4 and provides more typed support, which makes our code much more stable.

As for other people not updating their codes, I assume you are referring to external repositories, i.e. composer, npm those kinds of stuff. A rule of thumb from experienced programming is that if the developer no longer actively maintains a certain project, it’s doomed to be deprecated in the long run. Unmaintained projects even with open-source and accepted pull-request cannot sustain long as they struggle to keep up with the ever-evolving technological advancements out there.

:sparkles: If you devoted time and effort to your project, don’t waste it and keep it up! :sparkles:

The way to solve this can involve something like:

<?php

if (version_compare(PHP_VERSION, '8.0.0') >= 0) {
    echo 'Ayo! What\'s Up I\'m running PHP 8.0!';
}else{
    echo sprintf('Still too early, I\'m resting on PHP %s.', PHP_VERSION);
}

This way, your code adaptively supports both PHP 7.4 / 8.0, given that you did not use any function calls that are going to be removed in PHP 8.0.

Actually you can also do:

if(!function_exists('str_contains')){
    function str_contains($haystack, $needle){
        return stripos($haystack, $needle) !== false;
    }
}

Then take benefit of the PHP 8 function by deleting the condition and else case once you get upgraded. The technique here is to add a small implementation for PHP 8 functions in a 7.4 environment so that you can directly use PHP 8.0 functions immediately in your update. When your code gets updated to PHP 8.0, the function will be defined natively so your implementation will no longer be declared and can be safely removed as you have been using the same function names in your updated code and involves 0 downtime.

The above code example is specifically coded to demonstrate code replacement for checking substring existence. Previously the stripos sought the position of a string and converted it to a boolean value for consumption. This involves looping the characters under the hood in PHP’s C++ code. The new version can take advantage of binary search and simply return the boolean result directly, which is faster in terms of performance and easier reading in terms of code. Similar situations exist when fewer functions are available back in the day.

Best of all, you can search online and others may have already coded this for you, you can simply copy and paste it into your library/common/function include file, or have ChatGPT do this for you.

Hi ChatGPT, would you please write PHP 7.4 implementations for all new functions that are introduced in PHP 8.0? Please also add function_exists checking before each function declaration. All implementations should be type-safe and optimized for low memory usage and performance. Take advantage of existing PHP 7.4 native functions whenever possible.

In case you need to ask about specific packages, feel free to reply and we can have a look for you.

Cheers!

7 Likes

its great how you all respond in advanced way , thanks a lot for all

3 Likes

You’re most welcomed.

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.