你这样<?php
$conn = mysql_connect('localhost', 'root', '');
mysql_select_db('test');
$res = mysql_query("show variables like '%char%'");
$rows = array();
while ($rows[] = mysql_fetch_assoc($res));
print_r($rows);
mysql_query('set names "gbk";');
$res = mysql_query("show variables like '%char%'");
$rows = array();
while ($rows[] = mysql_fetch_assoc($res));
print_r($rows);
看返回结果, 我这边结果:Array
(
[0] => Array
(
[Variable_name] => character_set_client
[Value] => utf8
)
...
)
Array
(
[0] => Array
(
[Variable_name] => character_set_client
[Value] => gbk
)
...
)