mysql_real_escape_string在php8不能用,mysqli_escape_string需要mysqli。

pdo也有一个过滤非法字符函数就是quote(),在laravel中用法如下。

DB::connection()->getPdo()->quote()