How PHP writes Chinese into JSON when the JSON file also displays Chinese

Source: Internet
Author: User

/** * Updated version*/    functionshowupversionsub () {#accept the Post data .        $app _type=$_post[' Aap_type ']; if($app _type= = ' Android ' | |$app _type= = ' iOS ' | |$app _type= = ' windows '){            #make up an array            $arr=Array(Mainver=$_post[' Mainver ']==NULL? ‘‘:$_post[' Mainver '],Upver=$_post[' Upver ']==NULL? ‘‘:$_post[' Upver '],uptips=$_post[' Uptips ']==NULL? ‘‘:$_post[' Uptips '],Assetpath=$_post[' Assetpath ']==NULL? ‘‘:$_post[' Assetpath '],Newupinipath=$_post[' Newupinipath ']==NULL? ‘‘:$_post[' Newupinipath '],AppStore=$_post[' AppStore ']==NULL? ‘‘:$_post[' AppStore '],forceupdateversion=$_post[' Forceupdateversion ']==NULL? ‘‘ :$_post[' Forceupdateversion ']                ); #Convert to JSON string (Chinese compatible)            $str= Json_encode ($arr); $search= "#\\\u ([0-9a-f]{1,4}+) #ie"; $replace= "Iconv (' ucs-2be ', ' UTF-8 ', pack (' H4 ', ' \\1 ')"); $text=Preg_replace($search,$replace,$str); #file path            $url= "d:/www/gm_lequ/gm_lequ/".$app _type.‘ /update.ini '; #Determine if the path to the file exists to determine whether the directory exists we use Is_dir to OK.             if(file_exists($url)){                $fp=fopen($url, "w+"); #file lock prevents multiple people from writing files at the same time                if(Flock($fp,lock_ex)) {                    #Write Content                    fwrite($fp,$text); #file Unlock                    Flock($fp,Lock_un); $this->promptmsg = "Update succeeded!" "; }Else{                    $this->promptmsg = "Writing in file ... Please wait a moment! "; }            }Else{                $this->promptmsg = "File path does not exist"; }        }                $this->urljump = "index.php?module=operation&action=upversion&menuid=166"; $this-promptmsg (); }

How PHP writes Chinese into JSON when the JSON file also displays Chinese

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.