/** * 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