php源码
<?php //session start session_start(); include "./mobile/sql.php"; $con = mysql_connect($domain,$usrnm,$password); mysql_select_db($usrnm) or die('Could not select database'); mysql_query("set character set 'utf8'"); $page = $_GET['page']; if(!$con){ echo("can not connect"); } else{ //1.登陆授权 if($page=='login'){ //1.读取用户数据,并进行匹配 $usrname = $_GET['usrnm']; $pas = $_GET['pas']; //2.检索数据库 $sql = "select * from mb_usr"; $result = mysql_query($sql) or die('Query failed: ' . mysql_error()); while( $row = mysql_fetch_array($result) ){ if(($row['usrid']==$usrname || $row['mail']==$usrname || $row['phoneno']==$usrname) && $row['pas']==$pas){ //3.分配session值 保留登陆时限 $_SESSION[$usrname] = $usrname; //4.构建login的json格式 $jsonArr = Array('logintype'=>$row['usrtype'],'sessionid'=>$usrname,'usrnm'=>$row['usrnm'],'usrid'=>$row['usrid']); echo json_encode($jsonArr); break; } else{ echo '{"logintype":"-1"}'; } } } }?>
浏览器解析为
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">{"logintype":"0","sessionid":"0","usrnm":"mjc","usrid":"0"}
怎么将前一行去掉!
回复讨论(解决方案)
把相关程序文件转存为无bom的utf8文件就OK了。
方法最好用新建无bom文件,把代码复制过去,再保存。
php页面里去掉这句不就行了
json输出前加入
header('Content-type: application/json');
试试~
php页面里去掉这句不就行了
你找个地方去掉,我这个就没那个输出,估计是默认的,
include "./mobile/sql.php"; 这个里的吧
估计是 include "./mobile/sql.php"; 文件生成的吧,贴出来看看。
从来没有遇到过这样的奇葩问题了,呵呵
header("Content-type:application/json;charset=utf-8")
你肯定有include的页面里加这句了
咋去掉的啊 我也出现这种情况了
HTTP/1.1 200 OK
Date: Fri, 18 Apr 2014 09:00:59 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 4.0.30319
Content-Length: 2352
Cache-Control: private
Content-Type: application/json; charset=utf-8
{"body":{"item":[{"BuyPriceoff":0,"BuyTime":"未确定","CityId":420100,"CityName":"武汉","Content":"白色的年前提车","CountyId":420105,"CountyName":"汉阳","CreateTime":"2014-02-06 11:35:27","DealerId":11569,"HandleTime":"2014-01-07 11:35:28","Id":23010786,"Name":"张国雄","OrderType":0,"Phone":"18108624658","ProvinceId":420000,"ProvinceName":"湖北","ReDealerId":11569,"SeriesId":2945,"SeriesName":"雪铁龙C4L","SpecId":15737,"SpecName":"雪铁龙C4L 2013款 1.8L 手动劲智版","State":1},{"BuyPriceoff":0,"BuyTime":"","CityId":140100,"CityName":"太原","Content":"","CountyId":140105,"CountyName":"小店","CreateTime":"2014-02-06 11:34:35","DealerId":6752,"HandleTime":"2014-01-07 11:34:36","Id":23010726,"Name":"栗","OrderType":1,"Phone":"15386885719","ProvinceId":140000,"ProvinceName":"山西","ReDealerId":6752,"SeriesId":792,"SeriesName":"雪铁龙C5","SpecId":17043,"SpecName":"雪铁龙C5 2013款 2.0L 自动悦享型","State":1},{"BuyPriceoff":0,"BuyTime":"","CityId":440300,"CityName":"深圳","Content":"","CountyId":0,"CountyName":"","CreateTime":"2014-01-07 11:34:30","DealerId":75882,"HandleTime":"","Id":23010715,"Name":"黎","OrderType":0,"Phone":"18320819196","ProvinceId":440000,"ProvinceName":"广东","ReDealerId":0,"SeriesId":2945,"SeriesName":"雪铁龙C4L","SpecId":17658,"SpecName":"雪铁龙C4L 2014款 1.8L 自动智驱版劲智型 ","State":0},{"BuyPriceoff":0,"BuyTime":"","CityId":320300,"CityName":"徐州","Content":"","CountyId":0,"CountyName":"","CreateTime":"2014-01-07 11:34:04","DealerId":5248,"HandleTime":"","Id":23010688,"Name":"吴","OrderType":0,"Phone":"13852043028","ProvinceId":320000,"ProvinceName":"江苏","ReDealerId":0,"SeriesId":2945,"SeriesName":"雪铁龙C4L","SpecId":15739,"SpecName":"雪铁龙C4L 2013款 1.8L 自动劲驰版","State":0},{"BuyPriceoff":0,"BuyTime":"","CityId":440300,"CityName":"深圳","Content":"铂金灰","CountyId":0,"CountyName":"","CreateTime":"2014-02-06 11:33:39","DealerId":9802,"HandleTime":"2014-01-07 11:33:40","Id":23010669,"Name":"潘","OrderType":0,"Phone":"13923846836","ProvinceId":440000,"ProvinceName":"广东","ReDealerId":9802,"SeriesId":2945,"SeriesName":"雪铁龙C4L","SpecId":14551,"SpecName":"雪铁龙C4L 2013款 1.6L 手动劲智版","State":1}],"pages":40337,"total":201683},"cache":1000,"message":"","success":1,"result":0}NULL

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

PHP and Python are both high-level programming languages that are widely used in web development, data processing and automation tasks. 1.PHP is often used to build dynamic websites and content management systems, while Python is often used to build web frameworks and data science. 2.PHP uses echo to output content, Python uses print. 3. Both support object-oriented programming, but the syntax and keywords are different. 4. PHP supports weak type conversion, while Python is more stringent. 5. PHP performance optimization includes using OPcache and asynchronous programming, while Python uses cProfile and asynchronous programming.

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values and handle functions that may return null values.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Linux new version
SublimeText3 Linux latest version

Dreamweaver Mac version
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SublimeText3 Mac version
God-level code editing software (SublimeText3)