1

In a old project that I am migrating I used the old adldap. But now I have to change PHP version and old adldap doesn't work with the error:

HP Fatal error: Array and string offset access syntax with curly braces is no longer supported in /var/www/adLDAP/lib/adLDAP/classes/adLDAPUsers.php on line 764

The code which makes the problem is this:

public function encodePassword($password) {
    $password="\"".$password."\"";
    $encoded="";
    for ($i=0; $i <strlen($password); $i++) { $encoded.="{$password{$i}}\000"; }
    return $encoded;
}

The problem is this line:

for ($i=0; $i <strlen($password); $i++) { $encoded.="{$password{$i}}\000"; }

How can I fix it until I move to new system?

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
Matzewob
  • 19
  • 1
  • You just need to use square brackets for the array portion `{$password[$i]}`. This is where a good IDE would give you hints and be able to automatically fix things like this for you, too. – Chris Haas Mar 14 '22 at 19:54
  • Thank you, that solved the Problem for me. :-) – Matzewob Mar 14 '22 at 20:35

1 Answers1

0

Change:

$encoded.="{$password{$i}}\000";

To:

$encoded.="{$password[$i]}\000";
James Risner
  • 5,451
  • 11
  • 25
  • 47
kovarov
  • 465
  • 5
  • 11