Maison >développement back-end >tutoriel php >请教为什么,json_decode转uft-8字符串,结果为null
请问为什么,json_decode转uft-8字符串,结果为null?
<html> <html><head><meta http-equiv="Content-Type" content="text/html;charset=utf-8"/></head><br /><?php<br /><br />$str=isset($_POST["text"]) ? filter_input(INPUT_POST,"text",FILTER_SANITIZE_SPECIAL_CHARS) : '';<br />print "$str=".$str."\n";<br />if (strlen($str)>0){<br />//$str=mb_convert_encoding($str,"GBK","UTF-8");<br />$jo=json_decode($str); //中文的,转出来是null<br />print_r("\n++++\n".$jo."\n====\n"); <br />$msg_id=$jo->msg_id; //这里就会报错了。<br />}<br /><br /><br />echo ' <form method="post" action="t1.php">';<br />echo ' <textarea name="text" rows="2" cols="80">{"name":"test","id":0,"txt":"中文"}</textarea><br>';<br />echo ' <input type="submit"></form>';<br /><br /><br />?>