加入收藏 | 设为首页 | 会员中心 | 我要投稿 我爱资讯网 (https://www.52junxun.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php编码 js解码,php编码 js解码

发布时间:2022-10-06 12:36:32 所属栏目:PHP教程 来源:
导读:  通常是在一个循环中读取查询结果的,于是可以有while($row = mysql_assoc($rs)) { $t = array(); foreach($row as $k=>$v) $t[] = "\"$k\":\"$v\""; $res = '{' . join('},{', $t) . '}&#39
  通常是在一个循环中读取查询结果的,于是可以有while($row = mysql_assoc($rs)) { $t = array(); foreach($row as $k=>$v) $t[] = "\"$k\":\"$v\""; $res = '{' . join('},{', $t) . '}';}$json = '[' . join('],[', $res) .']';
 
  我的代码是这样取值的
 
  for($count=0; $row = $result->fetch_object(); $count++)
 
  {
 
  $resultArray[$count]['ID'] = $row->CLIENTID;
 
  $resultArray[$count]['money'] = $row->PAYNUM;
 
  $resultArray[$count]['Title'] = $row->PROJECTID;
 
  $resultArray[$count]['Mobile'] = $row->MOBILENUM;
 
  $resultArray[$count]['SMS_Content'] = $row->SMS;
 
  $resultArray[$count]['Date'] = $row->CREATETIME;
 
  }
 
  PHP不是有自动封装JSON的方法吗?json_encode($resultArray).就是这个啊.
 
  我不懂你的这个方法目的是什么?
 
  通常是在一个循环中读取查询结果的,于是可以有while($row = mysql_assoc($rs)) { $t = array(); foreach($row as $k=>$v) $t[] = "\"$k\":\"$v\""; $res = '{' . join('},{', $t) . '}';}$json = '[' . join('],[', $res) .']';
 
  我的代码是这样取值的
 
  for($count=0; $row = $result->fetch_object(); $count++)
 
  {
 
  $resultArray[$count]['ID'] = $row->CLIENTID;
 
  $resultArray[$count]['money'] = $row->PAYNUM;
 
  $resultArray[$count]['Title'] = $row->PROJECTID;
 
  $resultArray[$count]['Mobile'] = $row->MOBILENUM;
 
  $resultArray[$count]['SMS_Content'] = $row->SMS;
 
  $resultArray[$count]['Date'] = $row->CREATETIME;
 
  }
 
  PHP不是有自动封装JSON的方法吗?json_encode($resultArray).就是这个啊.
 
  我不懂你的这个方法目的是什么?
 
  既然你的php版本已经支持 json_encode 了,那你还用问什么?
 
  既然你那样问,当然认为是你的环境不支持 json_encode 函数了
 
  既然你的php版本已经支持 json_encode 了,那你还用问什么?
 
  既然你那样问,当然认为是你的环境不支持 json_encode 函数了
 
  不是的,是有中文,JSON无法很好的使用.到了前台页面,就直接是null,或者是乱码
 
  json_encode 只对 utf-8 编码有效,你要么转成 utf-8 的,要么就有我给的方法
 
  json_encode 只对 utf-8 编码有效,你要么转成 utf-8 的,要么就有我给的方法
 
  谢谢,已经搞定了.
 
  我的中文数据发送流程是 JS - php -mysql ,取出是 mysql- php - json - js -html 页面.
 
  现在我的处理方法是,
 
  在数据JS 向 PHP 传送前,
 
  $html=iconv("GB2312","UTF-8//IGNORE",$html);
 
  PHP-mysql 前
 
  $html= urldecode($html);
 
  然后,取出来的时候按正常的流程就行了.不需要做什么处理.
 
  本文原创发布php中文网php编码,转载请注明出处,感谢您的尊重!
 

(编辑:我爱资讯网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!