• PHP Deprecated: preg_split(): Passing null to parameter #3 ($limit) of type int is deprecated in db/SafeMySQL.php

    In PHP 8.1 and later, passing null to the preg_split function’s $limit parameter is deprecated. The preg_split function expects an integer for the $limit parameter.

    In your function, preg_split('~(\?[nsiuap])~u',$raw,null,PREG_SPLIT_DELIM_CAPTURE); uses null for the $limit parameter. To fix this, you can change null to -1, which is the default value indicating no limit.

    This is the culprit:

    private function prepareQuery($args)
    
    {
    
    ....
    
    $array = preg_split('~(\?[nsiuap])~u',$raw,null,PREG_SPLIT_DELIM_CAPTURE);
    
    ...
    
    }

    And this is a workaround:

    private function prepareQuery($args)
    {
       ...
        $array = preg_split('~(\?[nsiuap])~u', $raw, -1, PREG_SPLIT_DELIM_CAPTURE);
       ...
    }
  • The topic ‘PHP Deprecated: preg_split()’ is closed to new replies.