PHP查询MySQL 数据库后返回中文为问号
面向对象
1 $conn = new mysqli($servername,$user,$password); 3 增加 $conn->query("set names utf8");
$pdo = new PDO("mysql:host=$servername", $username, $password); 增加 $pdo->query("set names utf8");
面向过程
$conn = mysqli_connect($servername,$user,$password); 增加 mysqli_query($conn,"set names utf8");
原文链接:https://blog.csdn.net/qq_44721831/article/details/111241104