CodeIgniter 提交的中文是乱码?
本帖最后由 liren 于 2011-4-6 22:07 编辑CodeIgniter 是对中文支持不好吗? 我的html表单 <meta http-equiv="content-type" content="text/html; charset=gb2312" />
用户名:<INPUT TYPE="text" NAME="username">
后台的controller得到的中文是乱码!
大家遇到过吗 乱码只有一个原因:编码不统一。
和 PHP 和 CI 都无关。
仔细检查你的所有文件编码都是什么? 多谢回复,我的 application/config/config.php设置的也是 utf-8
/*
|--------------------------------------------------------------------------
| Default Character Set
|--------------------------------------------------------------------------
|
| This determines which character set is used by default in various methods
| that require a character set to be provided.
|
*/
$config['charset'] = 'UTF-8';
页面也是 <html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title><?php echo $title ?></title>
</head>
也没有其他地方可以设置编码了吧? 难道与apache和php.ini也有关系? php.ini 这句是注释了的:
; PHP's default character set is set to empty.
; http://php.net/default-charset
;default_charset = "iso-8859-1"
现在问题就是!
log_message('debug', 'Some variable 得到数据'.$username);//输出到文件乱码!
echo $username; //打印到浏览器上不是乱码!
CodeIgniter2.01诡异的log_message方法!谁帮我试试?!
本帖最后由 liren 于 2011-4-6 22:08 编辑各位朋友,下载安装了CodeIgniter2.01,遇到一个不解的问题! 谁帮我试试??特别奇怪!
很简单的代码:<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title><?php echo $title ?></title>
</head>
<body>
<TABLE border="1" bgcolor="#99CC99" height="400">
<TR>
<TD>
<?php echo form_open("home/home_logon"); ?>
用户名:<INPUT TYPE="text" NAME="username">
<INPUT TYPE="submit">
</form>
controller! 奇怪出在这里!
function home_logon(){
$username=$this->input->post("username");
$a="中文";
echo $username; //不是乱码! 正常打印到浏览器!
log_message('debug', 'Some variable 得到数据'.$a);//不是乱码! 正常!
log_message('debug', 'Some variable 得到数据'.$username);//乱码!!!
echo $username;//不是乱码! 正常打印到浏览器!
}
简直是邪门儿了! 怎么也解释不通啊!! :dizzy: 原來日志文件都要求格式!把 log-2011-04-06.php 格式另存為 UTF-8格式解決!要寫日志你用 .log后綴啊,也弄個.php。。。:dizzy: 回复 6# liren
用 .php 后缀有好处。。。。。
可以防止别人恶意下载你的日志文件。 本帖最后由 不能说的秘密 于 2012-5-16 12:25 编辑
这个问题已解决。http://www.itsqe.com/read.php?tid=167 里面写的很清楚。 不能说的秘密 发表于 2012-5-16 12:22 static/image/common/back.gif
这个问题已解决。http://www.itsqe.com/read.php?tid=167 里面写的很清楚。
http://www.itsqe.com/read.php?tid=16
页:
[1]