pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

  • <legend id='LehQj'><style id='LehQj'><dir id='LehQj'><q id='LehQj'></q></dir></style></legend>
  • <tfoot id='LehQj'></tfoot>

        <bdo id='LehQj'></bdo><ul id='LehQj'></ul>

      1. <i id='LehQj'><tr id='LehQj'><dt id='LehQj'><q id='LehQj'><span id='LehQj'><b id='LehQj'><form id='LehQj'><ins id='LehQj'></ins><ul id='LehQj'></ul><sub id='LehQj'></sub></form><legend id='LehQj'></legend><bdo id='LehQj'><pre id='LehQj'><center id='LehQj'></center></pre></bdo></b><th id='LehQj'></th></span></q></dt></tr></i><div class="lbdftr7" id='LehQj'><tfoot id='LehQj'></tfoot><dl id='LehQj'><fieldset id='LehQj'></fieldset></dl></div>

        <small id='LehQj'></small><noframes id='LehQj'>

        Zend_Cache:加載緩存數據后,字符編碼好像亂了

        Zend_Cache: After loading cached data, character encoding seems messed up(Zend_Cache:加載緩存數據后,字符編碼好像亂了)

          • <i id='VAkm0'><tr id='VAkm0'><dt id='VAkm0'><q id='VAkm0'><span id='VAkm0'><b id='VAkm0'><form id='VAkm0'><ins id='VAkm0'></ins><ul id='VAkm0'></ul><sub id='VAkm0'></sub></form><legend id='VAkm0'></legend><bdo id='VAkm0'><pre id='VAkm0'><center id='VAkm0'></center></pre></bdo></b><th id='VAkm0'></th></span></q></dt></tr></i><div class="jbrp5vl" id='VAkm0'><tfoot id='VAkm0'></tfoot><dl id='VAkm0'><fieldset id='VAkm0'></fieldset></dl></div>
              <bdo id='VAkm0'></bdo><ul id='VAkm0'></ul>
                  <tbody id='VAkm0'></tbody>

                  <legend id='VAkm0'><style id='VAkm0'><dir id='VAkm0'><q id='VAkm0'></q></dir></style></legend>
                1. <small id='VAkm0'></small><noframes id='VAkm0'>

                  <tfoot id='VAkm0'></tfoot>
                  本文介紹了Zend_Cache:加載緩存數據后,字符編碼好像亂了的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  第一;在我的開發服務器(本地主機;OSX 上的默認 XAMPP)上一切正常,但當我將完全相同的代碼(和數據)部署到臨時服務器(在 Redhat 上托管 Apache2)時,它會中斷.

                  First; On my development server (localhost; default XAMPP on OSX) everything works fine, though when I deploy the exact same code (and data) to the staging server (managed Apache2 on Redhat) it breaks.

                  我正在使用 Zend_Cache 使用文件后端和自動序列化緩存一些數據.原始數據中使用的特殊字符顯示正常,但當它們從緩存中加載時,它們都是亂碼.

                  I'm caching some data using Zend_Cache using the File backend and auto-serialization. Special characters used in the original data display fine, though when they are loaded from cache they're all garbled up.

                  有人知道嗎?

                  附注.我正在尋找一種方法來了解臨時服務器上可能出現的錯誤",而不是只是一種解決方法.什么可能會搞砸?

                  PS. Instead of just a workaround, I'm looking for a way to understand what might go "wrong" on the staging server. What could possibly mess this up?

                  更新我緩存的數據是 UTF-8 編碼的.

                  UPDATE The data I'm caching is UTF-8 encoded.

                  更新在查看原始緩存文件(序列化數組的)時,我看到了一個很大的不同;當暫存服務器上緩存的(相同)數據確實顯示換行符時,我的本地主機上緩存的數據不顯示換行符.

                  UPDATE When looking at the raw cache files (of a serialized array) there i See one big difference; The data cached on my localhost shows no newlines when the (identical) data cached on the staging server does show newlines.

                  更新本地服務器運行 PHP 5.3,臨時服務器運行 PHP 5.2.10

                  UPDATE Local server runs PHP 5.3, staging server runs PHP 5.2.10

                  更新在 Zend FW 1.10.8 上運行

                  UPDATE Running on Zend FW 1.10.8

                  推薦答案

                  我和你的情況幾乎一模一樣,

                  I have almost identical state like you ,

                  開發機器windows + php 5.3

                  development machine is windows + php 5.3

                  開發機為Linux + php 5.2.14

                  development machine is Linux + php 5.2.14

                  ZF 版本是 1.10

                  ZF version is 1.10

                  我唯一的區別是:我曾經在引導類中添加 mb_internal_encoding("UTF-8");

                  the only difference i had is : i used to add mb_internal_encoding("UTF-8"); in the bootstrap class

                  僅供參考,我曾經從數據庫中緩存所有編碼的 UTF8 文本(阿拉伯語)當我打開文件時,我看到了預期的阿拉伯語文本.

                  FYI , I used to cache text (arabic language ) from database all encoded UTF8 when i open the file i see the arabic text as expected .

                  更新:1- 這是我完整的 initCache 函數,只是為了清楚起見

                  UPDATE : 1- here is my complete initCache function just to make it clear

                  public function _initCache() {
                          mb_internal_encoding("UTF-8");
                          $frontendOptions = array(
                              'automatic_serialization' => TRUE,
                              'lifetime' => 86400
                          );
                          $backendOptions = array(
                              'cache_dir' => APPLICATION_PATH . "/configs/cache/",
                                  ///'cache_dir' => sys_get_temp_dir(),
                          );
                          $cache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions);
                          Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);
                          Zend_Registry::set("cache", $cache);
                      }
                  

                  說明:1-任何早于 PHP 6 的 php 版本都沒有對 UTF-8 的本機支持,https://stackoverflow.com/questions/716703/what-is-coming-in-php-6

                  Explanation : 1-Any php version earlier than PHP 6 doesn't have native support for UTF-8 , https://stackoverflow.com/questions/716703/what-is-coming-in-php-6

                  2-使 php 5.3 或 5.2 使用 ICONV 處理 UTF8或 MB_STRING

                  2-making php 5.3 or 5.2 deal with UTF8 by using ICONV or MB_STRING

                  只需使用 var_dump(mb_internal_encoding());

                  你可以在內部使用 ISO-8859-1 告訴 php,

                  you can tell that php using ISO-8859-1 internally ,

                  你可以通過var_dump(mb_internal_encoding("UTF-8"));

                  它會輸出真(它成功覆蓋內部編碼)

                  it would output true (it success to override the internal encoding )

                  老實說,我不知道是否有更好的解決方案或如何不好是嗎??,

                  to be honest i don't know if there is better solution or how bad it is ?? ,

                  如果你有更好的我會很樂意采用它:)

                  if you had any better i would be happy to adopt it :)

                  更新 2如果您不想使用該功能,打開這個文件 "Zend/Cache/Backend/File.php" 并轉到第 976 行改變這個:

                  UPDATE 2 in case you don't want to use that function , open this file "Zend/Cache/Backend/File.php" and go to the line 976 change this :

                  protected function _filePutContents($file, $string)
                  {
                  
                      $result = false;
                      $f = @fopen($file, 'ab+');
                      if ($f) {
                          if ($this->_options['file_locking']) @flock($f, LOCK_EX);
                          fseek($f, 0);
                          ftruncate($f, 0);
                          $tmp = @fwrite($f, $string);
                          if (!($tmp === FALSE)) {
                              $result = true;
                          }
                          @fclose($f);
                      }
                      @chmod($file, $this->_options['cache_file_umask']);
                      return $result;
                  }
                  

                  成為這樣:

                  protected function _filePutContents($file, $string)
                  {
                      $string = mb_convert_encoding($string   , "UTF-8" , "ISO-8859-1"); // i didn't test it , use it at your own risk and i'd rather stick with the first solution 
                      $result = false;
                      $f = @fopen($file, 'ab+');
                      if ($f) {
                          if ($this->_options['file_locking']) @flock($f, LOCK_EX);
                          fseek($f, 0);
                          ftruncate($f, 0);
                          $tmp = @fwrite($f, $string);
                          if (!($tmp === FALSE)) {
                              $result = true;
                          }
                          @fclose($f);
                      }
                      @chmod($file, $this->_options['cache_file_umask']);
                      return $result;
                  }
                  

                  我沒有手動測試,但它應該按預期工作

                  i didn't test manually but it should work as expected

                  很高興它有所幫助!

                  這篇關于Zend_Cache:加載緩存數據后,字符編碼好像亂了的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Deadlock exception code for PHP, MySQL PDOException?(PHP、MySQL PDOException 的死鎖異常代碼?)
                  PHP PDO MySQL scrollable cursor doesn#39;t work(PHP PDO MySQL 可滾動游標不起作用)
                  PHP PDO ODBC connection(PHP PDO ODBC 連接)
                  Using PDO::FETCH_CLASS with Magic Methods(使用 PDO::FETCH_CLASS 和魔術方法)
                  php pdo get only one value from mysql; value that equals to variable(php pdo 只從 mysql 獲取一個值;等于變量的值)
                  MSSQL PDO could not find driver(MSSQL PDO 找不到驅動程序)
                      <bdo id='K8w1k'></bdo><ul id='K8w1k'></ul>
                      <tfoot id='K8w1k'></tfoot>
                    • <legend id='K8w1k'><style id='K8w1k'><dir id='K8w1k'><q id='K8w1k'></q></dir></style></legend>

                      • <i id='K8w1k'><tr id='K8w1k'><dt id='K8w1k'><q id='K8w1k'><span id='K8w1k'><b id='K8w1k'><form id='K8w1k'><ins id='K8w1k'></ins><ul id='K8w1k'></ul><sub id='K8w1k'></sub></form><legend id='K8w1k'></legend><bdo id='K8w1k'><pre id='K8w1k'><center id='K8w1k'></center></pre></bdo></b><th id='K8w1k'></th></span></q></dt></tr></i><div class="h75nvj5" id='K8w1k'><tfoot id='K8w1k'></tfoot><dl id='K8w1k'><fieldset id='K8w1k'></fieldset></dl></div>

                        <small id='K8w1k'></small><noframes id='K8w1k'>

                            <tbody id='K8w1k'></tbody>

                            主站蜘蛛池模板: 深圳昂为官网-气体分析仪,沼气分析仪,动态配气仪,气体传感器厂家 | 箱式破碎机_移动方箱式破碎机/价格/厂家_【华盛铭重工】 | 玉米深加工设备-玉米深加工机械-新型玉米工机械生产厂家-河南粮院机械制造有限公司 | 全国国际学校排名_国际学校招生入学及学费-学校大全网 | 并离网逆变器_高频UPS电源定制_户用储能光伏逆变器厂家-深圳市索克新能源 | 盘扣式脚手架-附着式升降脚手架-移动脚手架,专ye承包服务商 - 苏州安踏脚手架工程有限公司 | 复合土工膜厂家|hdpe防渗土工膜|复合防渗土工布|玻璃纤维|双向塑料土工格栅-安徽路建新材料有限公司 | 螺杆真空泵_耐腐蚀螺杆真空泵_水环真空泵_真空机组_烟台真空泵-烟台斯凯威真空 | 船用泵,船用离心泵,船用喷射泵,泰州隆华船舶设备有限公司 | 定量包装机,颗粒定量包装机,粉剂定量包装机,背封颗粒包装机,定量灌装机-上海铸衡电子科技有限公司 | 校园气象站_超声波气象站_农业气象站_雨量监测站_风途科技 | jrs高清nba(无插件)直播-jrs直播低调看直播-jrs直播nba-jrs直播 上海地磅秤|电子地上衡|防爆地磅_上海地磅秤厂家–越衡称重 | 天津蒸汽/热水锅炉-电锅炉安装维修直销厂家-天津鑫淼暖通设备有限公司 | 恒温槽_恒温水槽_恒温水浴槽-上海方瑞仪器有限公司 | 隔离变压器-伺服变压器--输入输出电抗器-深圳市德而沃电气有限公司 | 电磁辐射仪-电磁辐射检测仪-pm2.5检测仪-多功能射线检测仪-上海何亦仪器仪表有限公司 | 钢骨架轻型板_膨石轻型板_钢骨架轻型板价格_恒道新材料 | 桁架楼承板-钢筋桁架楼承板-江苏众力达钢筋楼承板厂 | 事迹材料_个人事迹名人励志故事 学生作文网_中小学生作文大全与写作指导 | 食品无尘净化车间,食品罐装净化车间,净化车间配套风淋室-青岛旭恒洁净技术有限公司 | 安徽千住锡膏_安徽阿尔法锡膏锡条_安徽唯特偶锡膏_卡夫特胶水-芜湖荣亮电子科技有限公司 | 实木家具_实木家具定制_全屋定制_美式家具_圣蒂斯堡官网 | EPDM密封胶条-EPDM密封垫片-EPDM生产厂家 | 高压互感器,电流互感器,电压互感器-上海鄂互电气科技有限公司 | 英国雷迪地下管线探测仪-雷迪RD8100管线仪-多功能数字听漏仪-北京迪瑞进创科技有限公司 | 酒精检测棒,数显温湿度计,酒安酒精测试仪,酒精检测仪,呼气式酒精检测仪-郑州欧诺仪器有限公司 | 苏州西朗门业-欧盟CE|莱茵UL双认证的快速卷帘门品牌厂家 | 货车视频监控,油管家,货车油管家-淄博世纪锐行电子科技 | 医院专用门厂家报价-医用病房门尺寸大全-抗菌木门品牌推荐 | 微波萃取合成仪-电热消解器价格-北京安合美诚科学仪器有限公司 | 除甲醛公司-甲醛检测治理-杭州创绿家环保科技有限公司-室内空气净化十大品牌 | 灌木树苗-绿化苗木-常绿乔木-价格/批发/基地 - 四川成都途美园林 | 重庆私家花园设计-别墅花园-庭院-景观设计-重庆彩木园林建设有限公司 | 液压压力机,液压折弯机,液压剪板机,模锻液压机-鲁南新力机床有限公司 | 菏泽知彼网络科技有限公司 | 贴片电容代理-三星电容-村田电容-风华电容-国巨电容-深圳市昂洋科技有限公司 | 纸塑分离机-纸塑分离清洗机设备-压力筛-碎浆机厂家金双联环保 | 青岛侦探_青岛侦探事务所_青岛劝退小三_青岛婚外情取证-青岛王军侦探事务所 | 全自动翻转振荡器-浸出式水平振荡器厂家-土壤干燥箱价格-常州普天仪器 | 合肥角钢_合肥槽钢_安徽镀锌管厂家-昆瑟商贸有限公司 | 阿里巴巴诚信通温州、台州、宁波、嘉兴授权渠道商-浙江联欣科技提供阿里会员办理 |