deprecated functionality trim() passing null to parameter #1 ($string) of type string is deprecated

448 views Asked by At

I'm using Magento 2.4.5, But after installing extension for pincode checker (V4U), I'm getting following error on frontend (While checking pincode ). Can you please help me with this?

Deprecated functionality:trim():passing null to parameter #1 ($string) of type string is deprecated in C:/xampp/htdocs/magento2/app/code/V4U/ZipChecker/controller/ZipChecker/ZipChecker.php on line 76

Support will be mean a lot to me!

Need to fixed this error, please help.!

1

There are 1 answers

0
Utmost Creator On

I think it can be triggered in PHP 8.1 and later versions because passing null to string functions is deprecated.

// your code
$result = trim($variable);

// change to this to prevent deprecated warning
$result = trim($variable ?? '');

You can test it using this link