PHP 7.2.24 to PHP 8.1.2

tushar

New member
Below function works well in PHP 7.2.24.
Code:
public function escapeLike($string) {
    return addcslashes($string, '\%_');
  }
now trying the same in PHP 8.1.2, I am encountering following error:

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

please let me know what is to be changed.

thanks in advance!!
 
Add type in parameter:
Code:
 public function escapeLike(string $string) {
    return addcslashes($string, '\%_');
}
then you will see where the null is passing to the function
 
Back
Top