php形成json语句,多出前面一句,怎么去掉!
php源码
<br /> <br /> <?php<br /> //session start<br /> session_start();<br /> include "./mobile/sql.php";<br /> $con = mysql_connect($domain,$usrnm,$password);<br /> mysql_select_db($usrnm) or die('Could not select database'); <br /> mysql_query("set character set 'utf8'");<br /> $page = $_GET['page'];<br /> <br /> <br /> if(!$con){<br /> <br /> echo("can not connect");<br /> }<br /> else{<br /> //1.登陆授权<br /> if($page=='login'){<br /> //1.读取用户数据,并进行匹配<br /> $usrname = $_GET['usrnm'];<br /> $pas = $_GET['pas'];<br /> <br /> //2.检索数据库<br /> $sql = "select * from mb_usr";<br /> $result = mysql_query($sql) or die('Query failed: ' . mysql_error());<br /> <br /> while( $row = mysql_fetch_array($result) ){<br /> <br /> if(($row['usrid']==$usrname || $row['mail']==$usrname || $row['phoneno']==$usrname) && $row['pas']==$pas){<br /> //3.分配session值 保留登陆时限<br /> $_SESSION[$usrname] = $usrname;<br /> <br /> //4.构建login的json格式<br /> $jsonArr = Array('logintype'=>$row['usrtype'],'sessionid'=>$usrname,'usrnm'=>$row['usrnm'],'usrid'=>$row['usrid']);<br /> <br /> echo json_encode($jsonArr);<br /> <br /> break;<br /> }<br /> else{<br /> echo '{"logintype":"-1"}';<br /> }<br /> }<br /> }<br /> <br /> }<br /> <br /> <br /> ?><br /> <br />
<br /> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><br /> {"logintype":"0","sessionid":"0","usrnm":"mjc","usrid":"0"}<br /> <br />