0
 function decode($encoded, $key)
 {
        $strofsym = "qwertyuiopasdfghjklzxcvbnm1234567890QWERTYUIOPASDFGHJKLZXCVBNM="; 
        $x = 0;
        while ($x++<= strlen($strofsym))
        {
            $tmp = md5(md5($key.$strofsym[$x-1]).$key);
            $encoded = str_replace($tmp[3].$tmp[6].$tmp[1].$tmp[2], 
            $strofsym[$x-1], $encoded);
        }
        return base64_decode($encoded);
 }

when switching to PHP 8 I get the following error. on PHP 7.2 works well. Warning: Undefined array key 63 in line 7 and 8 HElp me, please.

2
  • Just to be clear, neither the Notice raised by PHP 7.2 nor the Warning raised by PHP 8.0 actually stops this code working. They are just telling you that you might have made a mistake somewhere. Commented Feb 9, 2021 at 19:01
  • Also note: the code you've shown doesn't give the Warning in your title. Please make sure to test that the code examples you post reproduce the error you want help with. Commented Feb 9, 2021 at 19:05

1 Answer 1

2

In PHP7.2 you will get a notice when accessing an uninitialized string offset. Since PHP8 this will raise a warning.
Your configuration probably ignore the notice but not the warning.

Ouput on different versions : https://3v4l.org/2AZRf

Change the condition from <= to < will fix the issue.

while ($x++ < strlen($strofsym))

More info to upgrade your code to PHP8 https://www.php.net/manual/en/migration80.incompatible.php

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.