PHP查询oracle数据显示乱码问题

1、Linux下   执行前脚本前先执行一下命令
export NLS_LANG="SIMPLIFIED CHINESE_CHINA.AL32UTF8"

2、Windows下在代码里添加 putenv("NLS_LANG=AMERICAN_AMERICA.AL32UTF8");
例:
header("content-type:text/html;charset=utf-8");
putenv("NLS_LANG=AMERICAN_AMERICA.AL32UTF8");
$conn = oci_connect('SYSTEM','root','localhost/orcl');
if (!$conn) {
$e = oci_error();
//print htmlentities($e['message']);
//WriteLog("连接Oracle时出错,oci_connect(".$db_user_name.",".$db_pwd.",".$db_host_name.") ".htmlentities($e['message']));
var_dump($e);exit;
}
$result_rows = oci_parse($conn, 'select * from CS'); // 配置SQL语句,执行SQL
$row_count = oci_execute($result_rows, OCI_DEFAULT); // 行数 OCI_DEFAULT表示不要自动commit

$count=[];
while($row = oci_fetch_array($result_rows, OCI_ASSOC)) {
// $fileType = mb_detect_encoding($row['SEX'] , array('UTF-8','GBK','LATIN1','BIG5')) ;
// if( $fileType != 'UTF-8'){
// $row['SEX'] = mb_convert_encoding($row['SEX'] ,'utf-8' , $fileType);
// }

$count[] = $row;
}
var_dump($count);exit;
上一篇:Dockerfile创建jdk镜像时环境变量写错,导致依赖该jdk生成的服务镜像创建容器出错


下一篇:域渗透-msdtc实现dll劫持后门