Ask why, Json_decode turn uft-8 string, result is null

Source: Internet
Author: User
Excuse me, why, Json_decode to uft-8 string, the result is null?


 
 
 

$str =isset ($_post["text"])? Filter_input (Input_post, "text", filter_sanitize_special_chars): ';
print "$str =". $str. " \ n ";
if (strlen ($STR) >0) {
$str =mb_convert_encoding ($str, "GBK", "UTF-8");
$jo =json_decode ($STR); Chinese, turn out to be null

$msg _id= $jo->msg_id; There will be an error here.
}


Echo ';


?>

------Solution--------------------
JSON format is not right, you put J to convert the JSON string echo out to see if it conforms to the standard JSON format
------Solution--------------------
Plus the back.
is not already in JSON format.
------Solution--------------------
Print_r ("\n++++\n". $jo. " \n====\n ");
What is this?

------Solution--------------------
echo $_post["text"];
Let's see what it is, it's mostly escaped with quotes.
  • 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.