3

I have this Code PHP in my Files

function getH1()
{
    $h1 = callDescriptor('h1');
    return ucfirst(substr($h1, 0, 56));
}

After Upgrade to PHP 8.1 i got this Error Messages:

Deprecated
    
substr(): Passing null to parameter #1 ($string) of type string is deprecated

Does someone have an Idee ?

Downgrade to PHP 8.0 takes the same Effekt

majas
  • 31
  • 1
  • 4

1 Answers1

1

The value of $h1 is null in some case which is not allowed to be passed inside of substr method. Check the value before processing it.

$h1 = callDescriptor('h1');
if ($h1 !== null) {
  return ucfirst(substr($h1, 0, 56));
}

//otherwise return something else